我有一个纯 Javascript 应用程序,它尝试使用带有 PKCE 的 OAuth 授权流程从 Azure 获取访问令牌。
该应用程序未托管在 Azure 中。我只使用 Azure 作为 OAuth 授权服务器。
//Based on: https://developer.okta.com/blog/2019/05/01/is-the-oauth-implicit-flow-dead
var config = {
client_id: "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx",
redirect_uri: "http://localhost:8080/",
authorization_endpoint: "https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/authorize",
token_endpoint: "https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/token",
requested_scopes: "openid api://{tenant-id}/user_impersonation"
};
// PKCE HELPER FUNCTIONS
// Generate a secure random string using the browser crypto functions
function generateRandomString() {
var array = new Uint32Array(28);
window.crypto.getRandomValues(array);
return Array.from(array, dec => ('0' + dec.toString(16)).substr(-2)).join('');
}
// Calculate the SHA256 hash of the input text.
// Returns a promise …Run Code Online (Sandbox Code Playgroud) 我已经按照这篇文章配置了 Azure AD 多租户身份验证:https ://docs.microsoft.com/en-us/azure/active-directory-b2c/identity-provider-azure-ad-multi-tenant-custom ?标签=应用程序
身份验证在上周星期五有效,但现在突然失败。我尝试使用两端添加的新 App Id 和新 App 机密在 Azure AD 中重新注册该应用程序。
我得到的错误:
抱歉,我们在登录时遇到问题。AADSTS9002325:跨域授权代码兑换需要代码交换证明密钥。
我是否忽略了一些明显的东西?
身份验证与使用 React 和react-aad-msal的 SPA Web 应用程序一起使用