yii2, google outh2 and scope

前端 未结 3 1266
陌清茗
陌清茗 2021-01-05 08:43

I am using Yii2, GoogleOAuth and yii2-user extension. I want to receive user google circles and set scope to my config:

\'authClientCollection\' => [
             


        
相关标签:
3条回答
  • 2021-01-05 09:08
    Use return URL in main.php like 
    
    'authClientCollection' => [
              'class' => 'yii\authclient\Collection',
              'clients' => [
                'facebook' => [
                  'class' => 'yii\authclient\clients\Facebook',
                  'authUrl' => 'https://www.facebook.com/dialog/oauth?display=popup',
                  'clientId' => ['FacebookClientId'],
                  'clientSecret' => ['FacebookClientSecret'],
                  'attributeNames' => ['name','first_name','last_name','email','gender','picture','age_range']
                ],
               'google' => [
                  'class' => 'yii\authclient\clients\Google',
                  'clientId' => ['GoogleClientId'],
                  'clientSecret' => ['GoogleClientSecret'],
                  'returnUrl' => 'http://yoursite.com/site/auth?authclient=google'
                ],
              ],
            ],
    
    
    Also set redirect_url in api credentials same as return url
    
    It's work for me.
    
    0 讨论(0)
  • 2021-01-05 09:14

    I was also facing this problem and got solution to change the Redirect URI in project Credentials like below:

    Redirect URIs

     http://mysiteurl.com/user/sign-in/oauth?authclient=google
     http://mysiteurl.com/oauth2callback
    

    JavaScript origins

     http://mysiteurl.com
    
    0 讨论(0)
  • 2021-01-05 09:17

    You can also add returnUrl explicitly in your auth client configuration. Look at docs for more info.

    0 讨论(0)
提交回复
热议问题