gpt4 book ai didi

azure - 了解 Oauth 2.0 授权代码流程

转载 作者:行者123 更新时间:2023-12-03 00:50:04 26 4
gpt4 key购买 nike

为什么我们需要首先联系 Oauth Auth 端点以获取身份验证代码,然后在收到身份验证代码后,我们需要再次联系 Oauth Auth 端点以获取访问 token ,以便我们可以调用 Web 服务?

为什么不在用户成功登录后在第一步中直接返回访问 token ?

此外,Web 服务 (API) 如何验证访问 token 是否合法?

最佳答案

Why do we need first contact the Oath Auth endpoint to get an auth code, and then once we have received the auth code we need to contact the Oauth Auth endpoint again to get the access token so that we can call a webservice?

因此 Web 服务(或依赖方)永远不会看到用户的凭据。由于此流程的工作方式,用户也无法看到应用程序的凭据。用户也无法获取访问 token 来自己使用它,尽管这实际上并不重要。隐式授权流程实际上可以满足您的要求,允许您直接从授权端点获取访问 token 。但这主要适用于单页应用程序,这是最简单的选择。授权代码授予流程允许应用通过客户端 key 或证书使用更强的身份验证。

顺便说一句,这被称为OAuth 舞蹈:)

Why not just return the access token in the first step, after the user has signed in successfully?

请参阅我上面提到的有关隐式授权流程的内容。

Also, how does the webservice (API) then verify that the access token is legit?

通过检查数字签名。 Azure AD(和 B2C)发布用于在众所周知的终结点进行签名的 key 对的公钥。应用程序中的身份验证部分必须通过定义的公钥检查 JWT 签名是否有效。

关于azure - 了解 Oauth 2.0 授权代码流程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48987125/

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