Oauth 無法取得 access token

匿名
2023-12-12T07:40:25+00:00

以下是我 APP 的設定

Web Redirect URL:

  • http://localhost/login/token

Single Redirect URL:

  • http://localhost/login/token

Implicit grant and hybrid flows

  • Access tokens (used for implicit flows)
  • ID tokens (used for implicit and hybrid flows)

Supported account types

  • Accounts in this organizational directory only

我使用以下 url 嘗試取得 authorization_code :

https://login.microsoftonline.com/{{TenantID}}/oauth2/v2.0/authorize?

client_id={{ClientID}}&

response_type=id_token&

redirect_uri=http%3A%2F%2Flocalhost%2Flogin%2Ftoken&

scope=openid&

response_mode=form_post&

nonce=678910  

以上 url 可以正常得到 authorization_code

接著我嘗試執行以下 request (Body 是為了方便閱讀才換行的)

URL: https://login.microsoftonline.com/{{TenantID}}/oauth2/v2.0/token

Method: POST

Header: Content-type: application/x-www-form-urlencoded

Body:
  client_id={{ClientID}}&
  client_secret={{ClientSecret}}&

  scope=openid&

  code={{authorization_code}}&

  grant_type=authorization_code

  redirect_uri=http%3A%2F%2Flocalhost%2Flogin%2Ftoken

但是卻回傳以下錯誤訊息:

{"error":"invalid_grant","error_description":"AADSTS9002313: Invalid request. Request is malformed or invalid. Trace ID: 12f61376-918d-421e-bc24-8fbeaa618300 Correlation ID: 1559c807-fcb0-4898-b656-bbb918424a95 Timestamp: 2023-12-12 07:08:47Z","error_codes":[9002313],"timestamp":"2023-12-12 07:08:47Z","trace_id":"12f61376-918d-421e-bc24-8fbeaa618300","correlation_id":"1559c807-fcb0-4898-b656-bbb918424a95","error_uri":"https://login.microsoftonline.com/error?code=9002313"}
適用於 IT 專業人員的 Windows 用戶端使用 Azure 虛擬桌面進行遠端和虛擬桌面驗證

鎖定的問題。 此問題已從 Microsoft 支援服務社群移轉。 您可以對其是否有幫助進行投票,但無法對問題新增註解或回覆,或進行追蹤。 為了保護隱私權,移轉問題的使用者設定檔會匿名。

0 則留言 沒有留言
{count} 則投票

3 個回答

排序依據: 最實用
  1. 匿名
    2023-12-13T00:52:22+00:00

    您好 IT-Tzuyang Tsai 蔡子揚,

    感谢您在 Microsoft 社区论坛上发帖。

    从上面的描述中,我了解到你的问题与 Azure/Microsoft Entra 有关。

    由于此论坛中没有专门负责 Azure/Microsoft Entra 的工程师。为了能够快速有效地处理您的问题,我建议您在Q&A论坛中重新发布您的问题,那里会有专门的工程师为您提供专业有效的回复。

    这是问答论坛的链接。

    Questions - Microsoft Q&A

    单击右上角的“提问”按钮发布您的问题,然后选择“Microsoft Entra”标签和与您的产品相关的任何其他 Azure 标签。

    我希望以上信息对您有所帮助。

    如果您有任何问题或疑虑,请随时告诉我们。

    Best Regards,
    Daisy Zhou

    0 則留言 沒有留言
  2. 匿名
    2023-12-13T03:12:37+00:00

    Daisy Zhou123

    謝謝您的回覆

    我有另外在 stackoverflow 那詢問,也在那邊找到解答了(https://stackoverflow.com/questions/77644816#comment136894674_77644816

    0 則留言 沒有留言
  3. 匿名
    2023-12-13T05:48:45+00:00

    您好 IT-Tzuyang Tsai 蔡子揚,

    下午好! 不客气,很高兴您的问题已经解决了。

    祝您工作生活愉快。

    Best Regards,
    Daisy Zhou

    0 則留言 沒有留言