azure - 使用 postman 生成不记名 token

标签 azure azure-active-directory postman

我已在 Azure AD 中注册了一个应用程序。我选择支持的帐户类型为“单租户”。我已授予 user.read、openid 和 profile 等权限。

现在,我正在尝试从 Postman 获取访问 token 。我给出了如下参数:

https://login.microsoftonline.com/mytenantid/oauth2/v2.0/token
client_id='myapp client id'
&scope=https://graph.microsoft.com/user.read
&redirect_uri=http://localhost
&grant_type=authorization_code
&client_secret='myapp client secret'

我收到以下错误:

AADSTS900144: The request body must contain the following parameter: 'code'.\r\nTrace ID: ffa4ba48-3287-4615-b6a3-aa71ed757400\r\nCorrelation ID: b375f781-2486-40d4-adee-826b9dc440ec\r\nTimestamp: 2022-04-21 12:13:10Z",

我不明白要提供什么代码以及如何查找代码值。 谁能帮帮我吗?

提前致谢。

最佳答案

要解决该错误,您必须在 Postman 中包含代码参数。

要获取该值,请尝试形成一个授权网址,如下所示:

https://login.microsoftonline.com/yourtenantid/oauth2/v2.0/authorize?client_id=yourclientid&response_type=code&redirect_uri=http://localhost&response_mode=query&scope=https://graph.microsoft.com/user.Read&state=skip_get_token2

并在浏览器中打开上述链接。在地址栏中您将获得代码的值。

Image

复制该代码值并在 postman 中添加该参数。

注意,该代码值只能使用一次。要再次获取代码值,您必须再次重复上述过程。

我在我的环境中尝试过,添加code参数后,成功获取了访问 token :

enter image description here

欲了解更多详情,请引用以下链接:

Microsoft identity platform and OAuth 2.0 authorization code flow - Microsoft identity platform | Microsoft Docs .

关于azure - 使用 postman 生成不记名 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72017597/

相关文章:

django - Azure 部署未在 repo 中获取 SSL 证书

azure - 无法删除 Kubernetes 服务 - Azure

java - 如何使用 Java 下载/上传 Azure B2C TrustFrameworkPolicy

azure - OAuth 2.0 SAML 承载断言流程

api - Http POST 在 Postman 中有效,但在 Flutter 中无效

azure - 无法读取 Azure IoT 中心 MQTT 订阅消息数据

azure - 如何将 TTL 添加到 Azure DocumentDB

azure - 无法通过 Azure Powershell 在新应用程序注册模块中设置 "preAuthorizedApplications"对象

ios - Postman - Firebase 通知 ios

json - 如何将带有字节数组的JSON发送到Web API/ postman