更改Microsoft Graph API Redirect Uri中的“code”参数

时间:2018-04-17 01:04:31

标签: azure-active-directory microsoft-graph azure-functions

我正在构建一个使用Microsoft Graph API进行身份验证的Azure Functions应用程序。我创建了一个processCode函数作为我的重定向URI,它使用Graph API发送的代码生成Graph令牌。

但是,Azure Functions在其调用中使用code查询字符串参数来传递功能键。

我是否可以将Graph API重定向URI配置为使用code以外的其他查询字符串参数?

基本上,改变

https://myapp/api/processCode?code=GRAPH-CODE (conflicting code parameter)

https://myapp/api/processCode?code=FUNCTIONS-KEY&graphcode=GRAPH-CODE

1 个答案:

答案 0 :(得分:4)

You cannot. The Tombstone query parameter is defined by the OAuth 2.0 specification (RFC 6249).

What you might be able to do instead is change your code= from response_mode to query when you request the authoirzation code. This changes how the code itself gets returned. Rather than issuing a form_post to your GET with the redirect_uri in the authorization it issues a code to the POST with the redirect_uri in the body (i.e. code).

You'd have to adjust your Azure Function to listen for application/x-www-form-urlencoded and parse the content from the body instead of the query string. Otherwise, everything should remain pretty much the same. The POST closely resembles the query string format (application/x-www-form-urlencoded).