从另一个 Microsoft 帐户的用户授予的授权代码中获取 access_token

问题描述 投票:0回答:1

我正在尝试从我的应用程序向另一个 Microsoft 帐户的用户访问 MS Graph API,以避免要求我们的客户必须自己创建应用程序

我可以通过此请求从用户同意中获取授权码:

https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=<clientId>&response_type=code&redirect_uri=<redirectURI>&response_mode=query&scope=User.Read.All&state=12345

我可以从另一个帐户读取用户,但只能读取一次,如果我尝试获取用户两次,我会收到此错误消息:

OAuth2 Authorization code was already redeemed, please retry with a new valid code or use an existing refresh token.

如果我尝试从

https://login.microsoftonline.com/<tenantId>/oauth2/v2.0/token
获取令牌 我收到此错误消息:

Provided Authorization Code is intended to use against other tenant, thus rejected. 

我只知道自己的clientId、tenantId和secret,不知道客户的tenantId是什么

如何解决我的问题? 谢谢

https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow

microsoft-graph-api token
1个回答
0
投票

我找到了解决办法: 我可以使用“common”而不是我的tenantId来获取accessToken

https://login.microsoftonline.com/common/oauth2/v2.0/token

© www.soinside.com 2019 - 2024. All rights reserved.