加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – yii2,谷歌outh2和范围

发布时间:2020-12-13 14:13:33 所属栏目:PHP教程 来源:网络整理
导读:我正在使用Yii2,GoogleOAuth和yii2用户扩展.我想接收用户谷歌圈子并将范围设置为我的配置: 'authClientCollection' = [ 'class' = 'yiiauthclientCollection','clients' = [ 'google' = [ 'class' = 'yiiauthclientclientsGoogleOAuth','clientId' = '
我正在使用Yii2,GoogleOAuth和yii2用户扩展.我想接收用户谷歌圈子并将范围设置为我的配置:
'authClientCollection' => [
        'class' => 'yiiauthclientCollection','clients' => [
            'google' => [
                'class' => 'yiiauthclientclientsGoogleOAuth','clientId' => '758709912345-p4qp4lqihit5un1u6qb75msqp5m5j6d8.apps.googleusercontent.com','clientSecret' => 'ZygOIi1-0asfktUQ1pKOFOo','scope' => 'https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/drive',],]

当我使用Google OAuth2登录时出现错误:

Exception – yiiauthclientInvalidResponseException
Request failed with code: 400,message: {
“error” : “redirect_uri_mismatch”
}

谷歌回应:

[
'url' => 'https://accounts.google.com/o/oauth2/token'
'content_type' => 'application/json'
'http_code' => 400
'header_size' => 435
'request_size' => 644
'filetime' => -1
'ssl_verify_result' => 0
'redirect_count' => 0
'total_time' => 0.115431
'namelookup_time' => 0.001186
'connect_time' => 0.025188
'pretransfer_time' => 0.076275
'size_upload' => 456
'size_download' => 39
'speed_download' => 337
'speed_upload' => 3950
'download_content_length' => -1
'upload_content_length' => 456
'starttransfer_time' => 0.114206
'redirect_time' => 0
'certinfo' => []
'primary_ip' => '2a00:1450:4010:c08::54'
'primary_port' => 443
'local_ip' => '2a03:6f00:1::5c35:726b'
'local_port' => 33160
'redirect_url' => ''

]

当我从配置中删除Google作用域(https://www.googleapis.com/auth/plus.login)授权时,请输出错误,Google的回复是:

[
'url' => 'https://accounts.google.com/o/oauth2/token'
'content_type' => 'application/json; charset=utf-8'
'http_code' => 200
'header_size' => 522
'request_size' => 526
'filetime' => -1
'ssl_verify_result' => 0
'redirect_count' => 0
'total_time' => 0.13719
'namelookup_time' => 0.001212
'connect_time' => 0.026261
'pretransfer_time' => 0.079765
'size_upload' => 338
'size_download' => 900
'speed_download' => 6560
'speed_upload' => 2463
'download_content_length' => -1
'upload_content_length' => 338
'starttransfer_time' => 0.136241
'redirect_time' => 0
'certinfo' => []
'primary_ip' => '2a00:1450:4010:c08::54'
'primary_port' => 443
'local_ip' => '2a03:6f00:1::5c35:726b'
'local_port' => 37583
'redirect_url' => ''

]

仅在https://www.googleapis.com/auth/plus.login中出现问题.我启用的API:http://minus.com/lJ5nw7caXJApD

您还可以在auth客户端配置中显式添加returnUrl.查看 docs获取更多信息.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读