Yii2 authclient not returning email id of user












3















Am using yii2-authclient for facebook login for my site, Am getting response like this



yiiauthclientclientsFacebook Object ( [authUrl] => https://www.facebook.com/dialog/oauth?display=popup [tokenUrl] => https://graph.facebook.com/oauth/access_token [apiBaseUrl] => https://graph.facebook.com [scope] => email [version] => 2.0 [clientId] => *******[clientSecret] => ********[_returnUrl:yiiauthclientBaseOAuth:private] => http://www.usermodule.com/index.php?r=site%2Fauth&authclient=facebook [_curlOptions:yiiauthclientBaseOAuth:private] => Array ( ) [_accessToken:yiiauthclientBaseOAuth:private] => yiiauthclientOAuthToken Object ( [tokenParamKey] => access_token [tokenSecretParamKey] => oauth_token_secret [createTimestamp] => 1436772538 [_expireDurationParamKey:yiiauthclientOAuthToken:private] => [_params:yiiauthclientOAuthToken:private] => Array ( [access_token] => ****************************** [expires] => 5182933 ) ) [_signatureMethod:yiiauthclientBaseOAuth:private] => Array ( ) [_id:yiiauthclientBaseClient:private] => facebook [_name:yiiauthclientBaseClient:private] => [_title:yiiauthclientBaseClient:private] => [_userAttributes:yiiauthclientBaseClient:private] => [_normalizeUserAttributeMap:yiiauthclientBaseClient:private] => [_viewOptions:yiiauthclientBaseClient:private] => [_events:yiibaseComponent:private] => Array ( ) [_behaviors:yiibaseComponent:private] => ) Array ( [name] => **** [id] => *****)


This is my config



 'authClientCollection' => [
'class' => 'yiiauthclientCollection',
'clients' => [
'facebook' => [
'class' => 'yiiauthclientclientsFacebook',
'clientId' => '***',
'clientSecret' => '****',

],
],
]


Am able to get username, user id but not user email id why? What else I should do?










share|improve this question





























    3















    Am using yii2-authclient for facebook login for my site, Am getting response like this



    yiiauthclientclientsFacebook Object ( [authUrl] => https://www.facebook.com/dialog/oauth?display=popup [tokenUrl] => https://graph.facebook.com/oauth/access_token [apiBaseUrl] => https://graph.facebook.com [scope] => email [version] => 2.0 [clientId] => *******[clientSecret] => ********[_returnUrl:yiiauthclientBaseOAuth:private] => http://www.usermodule.com/index.php?r=site%2Fauth&authclient=facebook [_curlOptions:yiiauthclientBaseOAuth:private] => Array ( ) [_accessToken:yiiauthclientBaseOAuth:private] => yiiauthclientOAuthToken Object ( [tokenParamKey] => access_token [tokenSecretParamKey] => oauth_token_secret [createTimestamp] => 1436772538 [_expireDurationParamKey:yiiauthclientOAuthToken:private] => [_params:yiiauthclientOAuthToken:private] => Array ( [access_token] => ****************************** [expires] => 5182933 ) ) [_signatureMethod:yiiauthclientBaseOAuth:private] => Array ( ) [_id:yiiauthclientBaseClient:private] => facebook [_name:yiiauthclientBaseClient:private] => [_title:yiiauthclientBaseClient:private] => [_userAttributes:yiiauthclientBaseClient:private] => [_normalizeUserAttributeMap:yiiauthclientBaseClient:private] => [_viewOptions:yiiauthclientBaseClient:private] => [_events:yiibaseComponent:private] => Array ( ) [_behaviors:yiibaseComponent:private] => ) Array ( [name] => **** [id] => *****)


    This is my config



     'authClientCollection' => [
    'class' => 'yiiauthclientCollection',
    'clients' => [
    'facebook' => [
    'class' => 'yiiauthclientclientsFacebook',
    'clientId' => '***',
    'clientSecret' => '****',

    ],
    ],
    ]


    Am able to get username, user id but not user email id why? What else I should do?










    share|improve this question



























      3












      3








      3


      2






      Am using yii2-authclient for facebook login for my site, Am getting response like this



      yiiauthclientclientsFacebook Object ( [authUrl] => https://www.facebook.com/dialog/oauth?display=popup [tokenUrl] => https://graph.facebook.com/oauth/access_token [apiBaseUrl] => https://graph.facebook.com [scope] => email [version] => 2.0 [clientId] => *******[clientSecret] => ********[_returnUrl:yiiauthclientBaseOAuth:private] => http://www.usermodule.com/index.php?r=site%2Fauth&authclient=facebook [_curlOptions:yiiauthclientBaseOAuth:private] => Array ( ) [_accessToken:yiiauthclientBaseOAuth:private] => yiiauthclientOAuthToken Object ( [tokenParamKey] => access_token [tokenSecretParamKey] => oauth_token_secret [createTimestamp] => 1436772538 [_expireDurationParamKey:yiiauthclientOAuthToken:private] => [_params:yiiauthclientOAuthToken:private] => Array ( [access_token] => ****************************** [expires] => 5182933 ) ) [_signatureMethod:yiiauthclientBaseOAuth:private] => Array ( ) [_id:yiiauthclientBaseClient:private] => facebook [_name:yiiauthclientBaseClient:private] => [_title:yiiauthclientBaseClient:private] => [_userAttributes:yiiauthclientBaseClient:private] => [_normalizeUserAttributeMap:yiiauthclientBaseClient:private] => [_viewOptions:yiiauthclientBaseClient:private] => [_events:yiibaseComponent:private] => Array ( ) [_behaviors:yiibaseComponent:private] => ) Array ( [name] => **** [id] => *****)


      This is my config



       'authClientCollection' => [
      'class' => 'yiiauthclientCollection',
      'clients' => [
      'facebook' => [
      'class' => 'yiiauthclientclientsFacebook',
      'clientId' => '***',
      'clientSecret' => '****',

      ],
      ],
      ]


      Am able to get username, user id but not user email id why? What else I should do?










      share|improve this question
















      Am using yii2-authclient for facebook login for my site, Am getting response like this



      yiiauthclientclientsFacebook Object ( [authUrl] => https://www.facebook.com/dialog/oauth?display=popup [tokenUrl] => https://graph.facebook.com/oauth/access_token [apiBaseUrl] => https://graph.facebook.com [scope] => email [version] => 2.0 [clientId] => *******[clientSecret] => ********[_returnUrl:yiiauthclientBaseOAuth:private] => http://www.usermodule.com/index.php?r=site%2Fauth&authclient=facebook [_curlOptions:yiiauthclientBaseOAuth:private] => Array ( ) [_accessToken:yiiauthclientBaseOAuth:private] => yiiauthclientOAuthToken Object ( [tokenParamKey] => access_token [tokenSecretParamKey] => oauth_token_secret [createTimestamp] => 1436772538 [_expireDurationParamKey:yiiauthclientOAuthToken:private] => [_params:yiiauthclientOAuthToken:private] => Array ( [access_token] => ****************************** [expires] => 5182933 ) ) [_signatureMethod:yiiauthclientBaseOAuth:private] => Array ( ) [_id:yiiauthclientBaseClient:private] => facebook [_name:yiiauthclientBaseClient:private] => [_title:yiiauthclientBaseClient:private] => [_userAttributes:yiiauthclientBaseClient:private] => [_normalizeUserAttributeMap:yiiauthclientBaseClient:private] => [_viewOptions:yiiauthclientBaseClient:private] => [_events:yiibaseComponent:private] => Array ( ) [_behaviors:yiibaseComponent:private] => ) Array ( [name] => **** [id] => *****)


      This is my config



       'authClientCollection' => [
      'class' => 'yiiauthclientCollection',
      'clients' => [
      'facebook' => [
      'class' => 'yiiauthclientclientsFacebook',
      'clientId' => '***',
      'clientSecret' => '****',

      ],
      ],
      ]


      Am able to get username, user id but not user email id why? What else I should do?







      yii2 yii-components yii2-advanced-app






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 13 '15 at 11:17







      user3377747

















      asked Jul 13 '15 at 7:37









      user3377747user3377747

      549




      549
























          5 Answers
          5






          active

          oldest

          votes


















          3














          Yes finally got the solution,



          when you make graph api request



          $this->makeSignedRequest('me');


          replace it with



          $this->makeSignedRequest('me?fields=id,name,email');


          either you are doing using facebook sdk or using yii2-eauth extension like me.
          if you are using yii2-eauth then you need to change this in vendor/nodge/yii2-eauth/src/services/FacebookOAuth2Service.php



          then add this line to read email attribute



          $this->attributes['email'] = $info['email'];


          Note: I tried yii way of passing argument like



          $this->makeSignedRequest('me',array('fields'=>'id,email');


          didn't work for me.



          Source of solution:
          https://developers.facebook.com/docs/php/howto/example_retrieve_user_profile/5.0.0






          share|improve this answer


























          • easily modificate passing arguments and it'll work $info = $this->makeSignedRequest('me',array( 'query' => array( 'fields' => 'email, name, birthday, gender, link, first_name, last_name, age_range', ), ));

            – Nikolaj Sarry
            Sep 23 '15 at 18:14













          • when to call $this->makeSignedRequest? sitecontroller?

            – Robert Limanto
            Feb 24 '16 at 16:53



















          2














          I got the solution with the help of above solutions.



          In yii2-authclient/clients/Facebook.php there is a function initUserAttributes() in which



           return $this->api('me', 'GET');


          replace it with



           return $this->api('me?fields=id,name,email', 'GET');





          share|improve this answer































            1














            Really there is some mistake from yii2 eauth extension.



            Firstly setting scope params in web.php



                        'facebook' => array(
            // register your app here: https://developers.facebook.com/apps/
            'clientId' => '454208034652365',
            'clientSecret' => '0e7161949129d4120cc5ac7d79f89098',
            'class' => 'nodgeeauthservicesFacebookOAuth2Service',
            'scope' => [
            'email'
            ]
            ),


            Then can you use like the following



              $info = $eauth->makeSignedRequest('me', [
            'query' => [
            'fields' => join(',', [
            'id',
            'name',
            'link',
            'email'
            ])
            ]
            ]);
            echo $info['email'];





            share|improve this answer































              0














                  for using Yii2-authclient you have to configure(main.php) like that:-
              inside components array write
              'authClientCollection' => [
              'class' => 'yiiauthclientCollection',
              'clients' => [
              'facebook' => [
              'class' => 'yiiauthclientclientsFacebook',
              'clientId' => 'your Client-Id',
              'clientSecret' => 'your Client-secret',
              ],

              ],
              ],
              in controller inside actions method write:-
              auth' => [
              'class' => 'yiiauthclientAuthAction',
              'successCallback' => [$this, 'successCallback'],
              ],

              then create successCallback function like
              public function successCallback($client)
              {
              $attributes= $client->getUserAttributes();
              print_r($attributes);
              }
              then you got all attributes which are shared by Facebook(like email, firstname etc).





              share|improve this answer
























              • Please read my question again, am getting response from facebook which I have shared in my question but in that am not getting email

                – user3377747
                Jul 13 '15 at 9:37











              • replace your config with given solution, then check

                – sprytechies
                Jul 13 '15 at 10:39











              • Done! response I got was Array ( [name] => ****** [id] => ***** ) . No email id

                – user3377747
                Jul 13 '15 at 10:51











              • are you register your app on developers.facebook.com

                – sprytechies
                Jul 13 '15 at 11:44











              • yea I have else I wont get even this response right

                – user3377747
                Jul 14 '15 at 3:53



















              0














              'facebook' => [
              'class' => 'yiiauthclientclientsFacebook',
              'clientId' => '****',
              'clientSecret' => '*****',
              ],


              That is enough. But sometime you still can not get email address because some facebook user do not has an email address:




              • facebook user register by phone

              • facebook user register by email but email not verified


              You have to catch it to notify the user.


              I don't know have any other exceptions. if user have an email but your app can not get that email address, let's check email permission in list Approved Items in "status and review" page on facebook developer to know why.
              https://developers.facebook.com/apps/YOUR_APP_ID/review-status/






              share|improve this answer
























              • I have fb account by email Id, I tested with my friend account also its same no email in response. Approved items email,public profile, user_friends shows approved by default.

                – user3377747
                Jul 13 '15 at 10:14













              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f31377753%2fyii2-authclient-not-returning-email-id-of-user%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              5 Answers
              5






              active

              oldest

              votes








              5 Answers
              5






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              3














              Yes finally got the solution,



              when you make graph api request



              $this->makeSignedRequest('me');


              replace it with



              $this->makeSignedRequest('me?fields=id,name,email');


              either you are doing using facebook sdk or using yii2-eauth extension like me.
              if you are using yii2-eauth then you need to change this in vendor/nodge/yii2-eauth/src/services/FacebookOAuth2Service.php



              then add this line to read email attribute



              $this->attributes['email'] = $info['email'];


              Note: I tried yii way of passing argument like



              $this->makeSignedRequest('me',array('fields'=>'id,email');


              didn't work for me.



              Source of solution:
              https://developers.facebook.com/docs/php/howto/example_retrieve_user_profile/5.0.0






              share|improve this answer


























              • easily modificate passing arguments and it'll work $info = $this->makeSignedRequest('me',array( 'query' => array( 'fields' => 'email, name, birthday, gender, link, first_name, last_name, age_range', ), ));

                – Nikolaj Sarry
                Sep 23 '15 at 18:14













              • when to call $this->makeSignedRequest? sitecontroller?

                – Robert Limanto
                Feb 24 '16 at 16:53
















              3














              Yes finally got the solution,



              when you make graph api request



              $this->makeSignedRequest('me');


              replace it with



              $this->makeSignedRequest('me?fields=id,name,email');


              either you are doing using facebook sdk or using yii2-eauth extension like me.
              if you are using yii2-eauth then you need to change this in vendor/nodge/yii2-eauth/src/services/FacebookOAuth2Service.php



              then add this line to read email attribute



              $this->attributes['email'] = $info['email'];


              Note: I tried yii way of passing argument like



              $this->makeSignedRequest('me',array('fields'=>'id,email');


              didn't work for me.



              Source of solution:
              https://developers.facebook.com/docs/php/howto/example_retrieve_user_profile/5.0.0






              share|improve this answer


























              • easily modificate passing arguments and it'll work $info = $this->makeSignedRequest('me',array( 'query' => array( 'fields' => 'email, name, birthday, gender, link, first_name, last_name, age_range', ), ));

                – Nikolaj Sarry
                Sep 23 '15 at 18:14













              • when to call $this->makeSignedRequest? sitecontroller?

                – Robert Limanto
                Feb 24 '16 at 16:53














              3












              3








              3







              Yes finally got the solution,



              when you make graph api request



              $this->makeSignedRequest('me');


              replace it with



              $this->makeSignedRequest('me?fields=id,name,email');


              either you are doing using facebook sdk or using yii2-eauth extension like me.
              if you are using yii2-eauth then you need to change this in vendor/nodge/yii2-eauth/src/services/FacebookOAuth2Service.php



              then add this line to read email attribute



              $this->attributes['email'] = $info['email'];


              Note: I tried yii way of passing argument like



              $this->makeSignedRequest('me',array('fields'=>'id,email');


              didn't work for me.



              Source of solution:
              https://developers.facebook.com/docs/php/howto/example_retrieve_user_profile/5.0.0






              share|improve this answer















              Yes finally got the solution,



              when you make graph api request



              $this->makeSignedRequest('me');


              replace it with



              $this->makeSignedRequest('me?fields=id,name,email');


              either you are doing using facebook sdk or using yii2-eauth extension like me.
              if you are using yii2-eauth then you need to change this in vendor/nodge/yii2-eauth/src/services/FacebookOAuth2Service.php



              then add this line to read email attribute



              $this->attributes['email'] = $info['email'];


              Note: I tried yii way of passing argument like



              $this->makeSignedRequest('me',array('fields'=>'id,email');


              didn't work for me.



              Source of solution:
              https://developers.facebook.com/docs/php/howto/example_retrieve_user_profile/5.0.0







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Jul 15 '15 at 5:28

























              answered Jul 15 '15 at 5:23









              user3377747user3377747

              549




              549













              • easily modificate passing arguments and it'll work $info = $this->makeSignedRequest('me',array( 'query' => array( 'fields' => 'email, name, birthday, gender, link, first_name, last_name, age_range', ), ));

                – Nikolaj Sarry
                Sep 23 '15 at 18:14













              • when to call $this->makeSignedRequest? sitecontroller?

                – Robert Limanto
                Feb 24 '16 at 16:53



















              • easily modificate passing arguments and it'll work $info = $this->makeSignedRequest('me',array( 'query' => array( 'fields' => 'email, name, birthday, gender, link, first_name, last_name, age_range', ), ));

                – Nikolaj Sarry
                Sep 23 '15 at 18:14













              • when to call $this->makeSignedRequest? sitecontroller?

                – Robert Limanto
                Feb 24 '16 at 16:53

















              easily modificate passing arguments and it'll work $info = $this->makeSignedRequest('me',array( 'query' => array( 'fields' => 'email, name, birthday, gender, link, first_name, last_name, age_range', ), ));

              – Nikolaj Sarry
              Sep 23 '15 at 18:14







              easily modificate passing arguments and it'll work $info = $this->makeSignedRequest('me',array( 'query' => array( 'fields' => 'email, name, birthday, gender, link, first_name, last_name, age_range', ), ));

              – Nikolaj Sarry
              Sep 23 '15 at 18:14















              when to call $this->makeSignedRequest? sitecontroller?

              – Robert Limanto
              Feb 24 '16 at 16:53





              when to call $this->makeSignedRequest? sitecontroller?

              – Robert Limanto
              Feb 24 '16 at 16:53













              2














              I got the solution with the help of above solutions.



              In yii2-authclient/clients/Facebook.php there is a function initUserAttributes() in which



               return $this->api('me', 'GET');


              replace it with



               return $this->api('me?fields=id,name,email', 'GET');





              share|improve this answer




























                2














                I got the solution with the help of above solutions.



                In yii2-authclient/clients/Facebook.php there is a function initUserAttributes() in which



                 return $this->api('me', 'GET');


                replace it with



                 return $this->api('me?fields=id,name,email', 'GET');





                share|improve this answer


























                  2












                  2








                  2







                  I got the solution with the help of above solutions.



                  In yii2-authclient/clients/Facebook.php there is a function initUserAttributes() in which



                   return $this->api('me', 'GET');


                  replace it with



                   return $this->api('me?fields=id,name,email', 'GET');





                  share|improve this answer













                  I got the solution with the help of above solutions.



                  In yii2-authclient/clients/Facebook.php there is a function initUserAttributes() in which



                   return $this->api('me', 'GET');


                  replace it with



                   return $this->api('me?fields=id,name,email', 'GET');






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Aug 5 '15 at 9:46









                  Mohd BashirMohd Bashir

                  611613




                  611613























                      1














                      Really there is some mistake from yii2 eauth extension.



                      Firstly setting scope params in web.php



                                  'facebook' => array(
                      // register your app here: https://developers.facebook.com/apps/
                      'clientId' => '454208034652365',
                      'clientSecret' => '0e7161949129d4120cc5ac7d79f89098',
                      'class' => 'nodgeeauthservicesFacebookOAuth2Service',
                      'scope' => [
                      'email'
                      ]
                      ),


                      Then can you use like the following



                        $info = $eauth->makeSignedRequest('me', [
                      'query' => [
                      'fields' => join(',', [
                      'id',
                      'name',
                      'link',
                      'email'
                      ])
                      ]
                      ]);
                      echo $info['email'];





                      share|improve this answer




























                        1














                        Really there is some mistake from yii2 eauth extension.



                        Firstly setting scope params in web.php



                                    'facebook' => array(
                        // register your app here: https://developers.facebook.com/apps/
                        'clientId' => '454208034652365',
                        'clientSecret' => '0e7161949129d4120cc5ac7d79f89098',
                        'class' => 'nodgeeauthservicesFacebookOAuth2Service',
                        'scope' => [
                        'email'
                        ]
                        ),


                        Then can you use like the following



                          $info = $eauth->makeSignedRequest('me', [
                        'query' => [
                        'fields' => join(',', [
                        'id',
                        'name',
                        'link',
                        'email'
                        ])
                        ]
                        ]);
                        echo $info['email'];





                        share|improve this answer


























                          1












                          1








                          1







                          Really there is some mistake from yii2 eauth extension.



                          Firstly setting scope params in web.php



                                      'facebook' => array(
                          // register your app here: https://developers.facebook.com/apps/
                          'clientId' => '454208034652365',
                          'clientSecret' => '0e7161949129d4120cc5ac7d79f89098',
                          'class' => 'nodgeeauthservicesFacebookOAuth2Service',
                          'scope' => [
                          'email'
                          ]
                          ),


                          Then can you use like the following



                            $info = $eauth->makeSignedRequest('me', [
                          'query' => [
                          'fields' => join(',', [
                          'id',
                          'name',
                          'link',
                          'email'
                          ])
                          ]
                          ]);
                          echo $info['email'];





                          share|improve this answer













                          Really there is some mistake from yii2 eauth extension.



                          Firstly setting scope params in web.php



                                      'facebook' => array(
                          // register your app here: https://developers.facebook.com/apps/
                          'clientId' => '454208034652365',
                          'clientSecret' => '0e7161949129d4120cc5ac7d79f89098',
                          'class' => 'nodgeeauthservicesFacebookOAuth2Service',
                          'scope' => [
                          'email'
                          ]
                          ),


                          Then can you use like the following



                            $info = $eauth->makeSignedRequest('me', [
                          'query' => [
                          'fields' => join(',', [
                          'id',
                          'name',
                          'link',
                          'email'
                          ])
                          ]
                          ]);
                          echo $info['email'];






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 23 '18 at 12:41









                          Gokhan AygunGokhan Aygun

                          111




                          111























                              0














                                  for using Yii2-authclient you have to configure(main.php) like that:-
                              inside components array write
                              'authClientCollection' => [
                              'class' => 'yiiauthclientCollection',
                              'clients' => [
                              'facebook' => [
                              'class' => 'yiiauthclientclientsFacebook',
                              'clientId' => 'your Client-Id',
                              'clientSecret' => 'your Client-secret',
                              ],

                              ],
                              ],
                              in controller inside actions method write:-
                              auth' => [
                              'class' => 'yiiauthclientAuthAction',
                              'successCallback' => [$this, 'successCallback'],
                              ],

                              then create successCallback function like
                              public function successCallback($client)
                              {
                              $attributes= $client->getUserAttributes();
                              print_r($attributes);
                              }
                              then you got all attributes which are shared by Facebook(like email, firstname etc).





                              share|improve this answer
























                              • Please read my question again, am getting response from facebook which I have shared in my question but in that am not getting email

                                – user3377747
                                Jul 13 '15 at 9:37











                              • replace your config with given solution, then check

                                – sprytechies
                                Jul 13 '15 at 10:39











                              • Done! response I got was Array ( [name] => ****** [id] => ***** ) . No email id

                                – user3377747
                                Jul 13 '15 at 10:51











                              • are you register your app on developers.facebook.com

                                – sprytechies
                                Jul 13 '15 at 11:44











                              • yea I have else I wont get even this response right

                                – user3377747
                                Jul 14 '15 at 3:53
















                              0














                                  for using Yii2-authclient you have to configure(main.php) like that:-
                              inside components array write
                              'authClientCollection' => [
                              'class' => 'yiiauthclientCollection',
                              'clients' => [
                              'facebook' => [
                              'class' => 'yiiauthclientclientsFacebook',
                              'clientId' => 'your Client-Id',
                              'clientSecret' => 'your Client-secret',
                              ],

                              ],
                              ],
                              in controller inside actions method write:-
                              auth' => [
                              'class' => 'yiiauthclientAuthAction',
                              'successCallback' => [$this, 'successCallback'],
                              ],

                              then create successCallback function like
                              public function successCallback($client)
                              {
                              $attributes= $client->getUserAttributes();
                              print_r($attributes);
                              }
                              then you got all attributes which are shared by Facebook(like email, firstname etc).





                              share|improve this answer
























                              • Please read my question again, am getting response from facebook which I have shared in my question but in that am not getting email

                                – user3377747
                                Jul 13 '15 at 9:37











                              • replace your config with given solution, then check

                                – sprytechies
                                Jul 13 '15 at 10:39











                              • Done! response I got was Array ( [name] => ****** [id] => ***** ) . No email id

                                – user3377747
                                Jul 13 '15 at 10:51











                              • are you register your app on developers.facebook.com

                                – sprytechies
                                Jul 13 '15 at 11:44











                              • yea I have else I wont get even this response right

                                – user3377747
                                Jul 14 '15 at 3:53














                              0












                              0








                              0







                                  for using Yii2-authclient you have to configure(main.php) like that:-
                              inside components array write
                              'authClientCollection' => [
                              'class' => 'yiiauthclientCollection',
                              'clients' => [
                              'facebook' => [
                              'class' => 'yiiauthclientclientsFacebook',
                              'clientId' => 'your Client-Id',
                              'clientSecret' => 'your Client-secret',
                              ],

                              ],
                              ],
                              in controller inside actions method write:-
                              auth' => [
                              'class' => 'yiiauthclientAuthAction',
                              'successCallback' => [$this, 'successCallback'],
                              ],

                              then create successCallback function like
                              public function successCallback($client)
                              {
                              $attributes= $client->getUserAttributes();
                              print_r($attributes);
                              }
                              then you got all attributes which are shared by Facebook(like email, firstname etc).





                              share|improve this answer













                                  for using Yii2-authclient you have to configure(main.php) like that:-
                              inside components array write
                              'authClientCollection' => [
                              'class' => 'yiiauthclientCollection',
                              'clients' => [
                              'facebook' => [
                              'class' => 'yiiauthclientclientsFacebook',
                              'clientId' => 'your Client-Id',
                              'clientSecret' => 'your Client-secret',
                              ],

                              ],
                              ],
                              in controller inside actions method write:-
                              auth' => [
                              'class' => 'yiiauthclientAuthAction',
                              'successCallback' => [$this, 'successCallback'],
                              ],

                              then create successCallback function like
                              public function successCallback($client)
                              {
                              $attributes= $client->getUserAttributes();
                              print_r($attributes);
                              }
                              then you got all attributes which are shared by Facebook(like email, firstname etc).






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Jul 13 '15 at 9:03









                              sprytechiessprytechies

                              28727




                              28727













                              • Please read my question again, am getting response from facebook which I have shared in my question but in that am not getting email

                                – user3377747
                                Jul 13 '15 at 9:37











                              • replace your config with given solution, then check

                                – sprytechies
                                Jul 13 '15 at 10:39











                              • Done! response I got was Array ( [name] => ****** [id] => ***** ) . No email id

                                – user3377747
                                Jul 13 '15 at 10:51











                              • are you register your app on developers.facebook.com

                                – sprytechies
                                Jul 13 '15 at 11:44











                              • yea I have else I wont get even this response right

                                – user3377747
                                Jul 14 '15 at 3:53



















                              • Please read my question again, am getting response from facebook which I have shared in my question but in that am not getting email

                                – user3377747
                                Jul 13 '15 at 9:37











                              • replace your config with given solution, then check

                                – sprytechies
                                Jul 13 '15 at 10:39











                              • Done! response I got was Array ( [name] => ****** [id] => ***** ) . No email id

                                – user3377747
                                Jul 13 '15 at 10:51











                              • are you register your app on developers.facebook.com

                                – sprytechies
                                Jul 13 '15 at 11:44











                              • yea I have else I wont get even this response right

                                – user3377747
                                Jul 14 '15 at 3:53

















                              Please read my question again, am getting response from facebook which I have shared in my question but in that am not getting email

                              – user3377747
                              Jul 13 '15 at 9:37





                              Please read my question again, am getting response from facebook which I have shared in my question but in that am not getting email

                              – user3377747
                              Jul 13 '15 at 9:37













                              replace your config with given solution, then check

                              – sprytechies
                              Jul 13 '15 at 10:39





                              replace your config with given solution, then check

                              – sprytechies
                              Jul 13 '15 at 10:39













                              Done! response I got was Array ( [name] => ****** [id] => ***** ) . No email id

                              – user3377747
                              Jul 13 '15 at 10:51





                              Done! response I got was Array ( [name] => ****** [id] => ***** ) . No email id

                              – user3377747
                              Jul 13 '15 at 10:51













                              are you register your app on developers.facebook.com

                              – sprytechies
                              Jul 13 '15 at 11:44





                              are you register your app on developers.facebook.com

                              – sprytechies
                              Jul 13 '15 at 11:44













                              yea I have else I wont get even this response right

                              – user3377747
                              Jul 14 '15 at 3:53





                              yea I have else I wont get even this response right

                              – user3377747
                              Jul 14 '15 at 3:53











                              0














                              'facebook' => [
                              'class' => 'yiiauthclientclientsFacebook',
                              'clientId' => '****',
                              'clientSecret' => '*****',
                              ],


                              That is enough. But sometime you still can not get email address because some facebook user do not has an email address:




                              • facebook user register by phone

                              • facebook user register by email but email not verified


                              You have to catch it to notify the user.


                              I don't know have any other exceptions. if user have an email but your app can not get that email address, let's check email permission in list Approved Items in "status and review" page on facebook developer to know why.
                              https://developers.facebook.com/apps/YOUR_APP_ID/review-status/






                              share|improve this answer
























                              • I have fb account by email Id, I tested with my friend account also its same no email in response. Approved items email,public profile, user_friends shows approved by default.

                                – user3377747
                                Jul 13 '15 at 10:14


















                              0














                              'facebook' => [
                              'class' => 'yiiauthclientclientsFacebook',
                              'clientId' => '****',
                              'clientSecret' => '*****',
                              ],


                              That is enough. But sometime you still can not get email address because some facebook user do not has an email address:




                              • facebook user register by phone

                              • facebook user register by email but email not verified


                              You have to catch it to notify the user.


                              I don't know have any other exceptions. if user have an email but your app can not get that email address, let's check email permission in list Approved Items in "status and review" page on facebook developer to know why.
                              https://developers.facebook.com/apps/YOUR_APP_ID/review-status/






                              share|improve this answer
























                              • I have fb account by email Id, I tested with my friend account also its same no email in response. Approved items email,public profile, user_friends shows approved by default.

                                – user3377747
                                Jul 13 '15 at 10:14
















                              0












                              0








                              0







                              'facebook' => [
                              'class' => 'yiiauthclientclientsFacebook',
                              'clientId' => '****',
                              'clientSecret' => '*****',
                              ],


                              That is enough. But sometime you still can not get email address because some facebook user do not has an email address:




                              • facebook user register by phone

                              • facebook user register by email but email not verified


                              You have to catch it to notify the user.


                              I don't know have any other exceptions. if user have an email but your app can not get that email address, let's check email permission in list Approved Items in "status and review" page on facebook developer to know why.
                              https://developers.facebook.com/apps/YOUR_APP_ID/review-status/






                              share|improve this answer













                              'facebook' => [
                              'class' => 'yiiauthclientclientsFacebook',
                              'clientId' => '****',
                              'clientSecret' => '*****',
                              ],


                              That is enough. But sometime you still can not get email address because some facebook user do not has an email address:




                              • facebook user register by phone

                              • facebook user register by email but email not verified


                              You have to catch it to notify the user.


                              I don't know have any other exceptions. if user have an email but your app can not get that email address, let's check email permission in list Approved Items in "status and review" page on facebook developer to know why.
                              https://developers.facebook.com/apps/YOUR_APP_ID/review-status/







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Jul 13 '15 at 9:54









                              Ngô Văn ThaoNgô Văn Thao

                              1,8751319




                              1,8751319













                              • I have fb account by email Id, I tested with my friend account also its same no email in response. Approved items email,public profile, user_friends shows approved by default.

                                – user3377747
                                Jul 13 '15 at 10:14





















                              • I have fb account by email Id, I tested with my friend account also its same no email in response. Approved items email,public profile, user_friends shows approved by default.

                                – user3377747
                                Jul 13 '15 at 10:14



















                              I have fb account by email Id, I tested with my friend account also its same no email in response. Approved items email,public profile, user_friends shows approved by default.

                              – user3377747
                              Jul 13 '15 at 10:14







                              I have fb account by email Id, I tested with my friend account also its same no email in response. Approved items email,public profile, user_friends shows approved by default.

                              – user3377747
                              Jul 13 '15 at 10:14




















                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f31377753%2fyii2-authclient-not-returning-email-id-of-user%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Wiesbaden

                              Marschland

                              Dieringhausen