yii2, google outh2 and scope

心不动则不痛 提交于 2019-11-30 20:20:39

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

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
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.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!