authentication - 当我尝试获取访问令牌时出现“为 'redirect_uri' 提供的值无效”错误
问题描述
当我尝试获取令牌时,出现错误:
The provided value for the 'redirect_uri' is not valid. The value must exactly match the redirect URI used to obtain the authorization code.
我的重定向 uri 完全匹配,所以我不明白为什么会这样。
$TOKEN_ENDPOINT = 'https://login.microsoftonline.com/common/oauth2/v2.0/token';
$params = array(
'grant_type' => 'authorization_code',
'code' => $azureCode,
'clientId' => '7c09ab71-***-****-****-53d7c4438112',
'clientSecret' => 'bnot*******20*[',
'redirect_uri' => 'https://testing.****.com/outlookOauthCallback.php',
'urlAuthorize' => $AUTHORIZATION_ENDPOINT,
'urlAccessToken' => $TOKEN_ENDPOINT,
'urlResourceOwnerDetails' => '',
'scope' => 'Calendars.ReadWrite User.Read'
);
$response = $client->getAccessToken($TOKEN_ENDPOINT, 'authorization_code', $params);
(相信我,我变成星星的部分完全一样,因为我是复制粘贴的)
即使在我返回参数的响应中,它也是完全相同的:
Array
(
[grant_type] => authorization_code
[code] => M51b1b*****-daeec54627b2
[clientId] => 7c09ab71-a*****d7c4438112
[clientSecret] => bnotxds&*&QB***cVLF20*[
[redirect_uri] => https://testing.****.com/outlookOauthCallback.php
[urlAuthorize] => https://login.microsoftonline.com/common/oauth2/v2.0/authorize
[urlAccessToken] => https://login.microsoftonline.com/common/oauth2/v2.0/token
[urlResourceOwnerDetails] =>
[scope] => Calendars.ReadWrite User.Read
)
那么它怎么还会给我这个错误呢?我在这里想念什么?
解决方案
您需要在请求 url 中指定 redirect_uri。就像是
var href = 'login.microsoftonline.com/common/oauth2/…'; href += client_id + '&resource=webdir.online.lync.com&redirect_uri=' + window.location.href;
推荐阅读
- firebase - 如何知道在 Flutter 应用中使用哪个版本的 Google Firebase 插件?
- sql - PL/SQL 创建一个根据日期范围检查 SYSDATE 的触发器
- python - 在 jinja2 中访问烧瓶动态路由值
- function - Python - 函数中的变量未定义
- python - 如何使用 Python 从 Chrome 获取下载目录位置
- python - 无法验证电话号码是否在文件中
- python - @api。取决于或 @api.onchange 不适用于计算字段。为什么?
- c - 编译正则表达式:出现成功错误
- android - Android Studio 在手机上运行时忽略 layout-large
- methods - 如何通过函数指针调用方法?