【问题标题】:Yii2 OpenId Connect error - yii2-authclient returns 400 error "Token not provided" when I try to getUserAttributes()Yii2 OpenId Connect 错误 - 当我尝试 getUserAttributes() 时,yii2-authclient 返回 400 错误“未提供令牌”
【发布时间】:2018-06-06 14:59:06
【问题描述】:

我正在使用 yii2-authclient 库在我的 Yii2 应用程序中实现 OpenId Connect。我可以毫无问题地登录并用代码交换令牌。我已经按照网络上的大多数代码示例设置了一个successCallback 函数,一旦用户成功登录就会调用该函数。它看起来像这样:

public function successCallback(ClientInterface $client) 
{
    $attributes = $client->getUserAttributes();
}

此代码被调用,但调用 getUserAttributes() 会导致以下错误:

异常 – yii\authclient\InvalidResponseException
请求失败,代码:400,消息:
{"error":"invalid_request","error_description":"令牌未提供"}

id 服务器上的日志显示一个空白的客户端和用户,错误为invalid_token

我仔细查看了我提出的请求,我看到了一个 access_token 元素。任何想法可能是什么问题?如有需要,我可以提供更多信息。

【问题讨论】:

  • 更多信息:这是我点击的 URL:https://id.dev.[url removed].com/auth/realms/terradatum/protocol/openid-connect/userinfo?access_token=eyJhb[rest of token removed] 并收到以下回复:{"error":"invalid_request","error_description":"Token not provided"}

标签: php yii2 openid-connect yii2-authclient


【解决方案1】:

我想通了。问题是 yii2-authclient 库将令牌作为 GET 参数发送,而 ID 服务器期望它作为 POST 参数。我升级了 yii2-authclient 库并解决了问题,因为最近的更改将参数发送为 POST 而不是 GET。

【讨论】:

    猜你喜欢
    • 2018-09-08
    • 2017-11-08
    • 1970-01-01
    • 2016-02-03
    • 1970-01-01
    • 2019-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多