【发布时间】:2018-05-09 01:06:05
【问题描述】:
我们正在尝试从旧的 WindowsLive API 迁移到新的 Microsoft Graph API。在此过程中,我们遇到了应用程序中所需的 OAuth 2.0 redirect_uri 参数的困难。
根据Oauth 2.0 RFC,redirect_uri 必须是绝对路径,但可以包含正确编码的查询字符串。
在我们的 Windows 应用中,我们设置了绝对路径 - 他们的应用工具不允许添加查询字符串:https://example.com/index.php
我们发出的 OAuth 请求使用带有 URL 编码的 redirect_uri,包括查询参数。这是必要的,我们使用 CMS (Joomla) 需要知道应该处理请求的内容:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?
response_type=code&
client_id={string}&
redirect_uri=https%3A%2F%2Fexample.com%2Findex.php%3Foption%3Dcom_jfbconnect%26task%3Dauthenticate.callback%26provider%3Dwindowslive&
scope=user.read&
state={string}&
access_type=offline&
approval_prompt=auto
但是,Graph API 拒绝这样做:
“请求中指定的回复url与为应用配置的回复url不匹配”
还有其他人遇到这种情况或了解为什么 Graph API 不接受应用配置或令牌请求中的查询参数吗?
编辑 - 5/8 - 但是,应用程序设置区域不允许在 redirect_uri 设置中允许查询字符串,根据 RFC,这是正确的。但是,Graph API 不尊重 RFC 的此注释:
The endpoint URI MAY include an "application/x-www-form-urlencoded" formatted (per Appendix B) query component ([RFC3986] Section 3.4), which MUST be retained when adding additional query parameters.
【问题讨论】:
标签: oauth-2.0 azure-active-directory microsoft-graph-api