gpt4 book ai didi

azure - 访问 token 给出不同的澳元?

转载 作者:行者123 更新时间:2023-12-02 06:16:00 24 4
gpt4 key购买 nike

我正在尝试通过 OAuth 使用 Azure 中的 API 管理进行身份验证。我已经把那部分设置得很好了。

我发生了 OAuth2 隐式登录流程,我获得了 ID token 和访问 token ( response_type=id_token+token )。当我检查aud时在返回的访问 token 中,我得到默认的 Graph API aud (00000003-0000-0000-c000-000000000000),而不是我的客户端 ID,我需要用它来通过 API 管理部分进行身份验证。

这需要保留在 OAuth 后面,因为它是一个内部应用程序,我不想向公众公开。我使用隐式流,因为该网页是 Blob 上托管的 SPA。

最佳答案

正如 junnas 所说,如果您想获取 clientId 的 aud,您需要为您的应用添加有效范围。

转到在 azure 广告中注册的应用的公开范围,然后添加范围

enter image description here

并在 url 中添加范围,如下所示:

https://login.microsoftonline.com/xxxx/oauth2/v2.0/authorize?
client_id=xxxxx
&response_type=id_token+token
&redirect_uri=https://localhost:123
&scope=openid api://xxxxxxxxxxxxxxxxxxxxxx-a3aab90df9fc/webread
&response_mode=fragment
&state=12345
&nonce=678910

然后解码访问 token ,您将在aud中获得客户端ID:

enter image description here

关于azure - 访问 token 给出不同的澳元?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60169485/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com