[英]Having issue with authclient in Yii2
I integrated social authentication based on this tutorial:我根据本教程集成了社交身份验证:
http://stuff.cebe.cc/yii2docs/guide-security-auth-clients.html http://stuff.cebe.cc/yii2docs/guide-security-auth-clients.html
Here is my configuration file:这是我的配置文件:
'authClientCollection' => [
'class' => 'yii\authclient\Collection',
'clients' => [
'facebook' => [
'class' => 'yii\authclient\clients\Facebook',
'clientId' => 'my_id',
'clientSecret' => 'my_secret',
],
'linkedin' => [
'class' => 'yii\authclient\clients\LinkedIn',
'clientId' => 'my_id',
'clientSecret' => 'my_secret',
],
],
],
My problem is, when I click on social buttons it redirects into login page.我的问题是,当我点击社交按钮时,它会重定向到登录页面。 I tried even something like that:我什至尝试过这样的事情:
public function onAuthSuccess($client) {
$attributes = $client->getUserAttributes();
die(print_r($attributes));
...
Even this doesn't work for me, it just 302 redirects into login page.即使这对我不起作用,它只是 302 重定向到登录页面。
What might be issue?可能是什么问题?
Maybe you are getting access_denied error ?也许您遇到了access_denied错误? because by default when get request from OAuth server contain error parameter and if it is equal to access_denied , the AuthAction redirects user to cancelUrl which is by default is loginUrl .因为默认情况下,当来自 OAuth 服务器的get请求包含错误参数并且如果它等于access_denied 时, AuthAction会将用户重定向到cancelUrl ,默认情况下为loginUrl 。
Try to set 'cancelUrl' => Url::to(['site/login', $_GET])
in auth action configuration, and check $_GET
parameters from OAuth server in url after redirect尝试在auth操作配置中设置'cancelUrl' => Url::to(['site/login', $_GET])
,并在重定向后检查 url 中来自 OAuth 服务器的$_GET
参数
Also redirect to cancelUrl happens if OAuthClient cannot fetch AccessToken如果OAuthClient无法获取AccessToken ,也会重定向到cancelUrl
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.