小编yer*_*585的帖子

在 PKCE 的 OAuth 授权流程中使用时,如何在 Azure 应用注册中启用 CORS?

我有一个纯 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)

javascript azure oauth-2.0 pkce

11
推荐指数
2
解决办法
7505
查看次数

标签 统计

azure ×1

javascript ×1

oauth-2.0 ×1

pkce ×1