mardi 12 janvier 2016

Satellizer: Not returning email in login with facebook

I am using http://ift.tt/1pEY7GE for adding login with facebook functionality in my angular + laravel ( 5.2) application.

Here is the code I am using in php to call the facebook graph api

 $client = new GuzzleHttp\Client();

    $params = [
        'code' => $request->input('code'),
        'client_id' => $request->input('clientId'),
        'redirect_uri' => $request->input('redirectUri'),
        'client_secret' => Config::get('app.facebook_secret')
    ];

    // Step 1. Exchange authorization code for access token.
    $accessTokenResponse = $client->request('GET', 'http://ift.tt/1NFHIcT', [
        'query' => $params
    ]);
    $accessToken = json_decode($accessTokenResponse->getBody(), true);

    // Step 2. Retrieve profile information about the current user.
    $profileResponse = $client->request('GET', 'http://ift.tt/1NFHJNU', [
        'query' => $accessToken
    ]);
    $profile = json_decode($profileResponse->getBody(), true); 

But it is only return id and name in the response. I have tried adding id,name and email as fields in the url as

 $profileResponse = $client->request('GET', 'http://ift.tt/1TS6cEz', [
        'query' => $accessToken
    ]);

Still it is returning only id and name.

I also tried it in Graph API Explorer with the token returned by the above request. It shows proper response.

enter image description here

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire