不同环境下使用msal.js可能会导致AuthenticationResults不同。
创始人
2025-01-09 03:30:22
0

使用相同的API访问同一环境中的Web API。具体而言,需要确保使用的是相同的scopes和redirectUri,并确保在应用程序注册页面上为相同的应用程序定义了正确的回调URI。以下是代码示例:

var msalConfig = {
    auth: {
        clientId: 'your_client_id',
        redirectUri: 'https://localhost:3000/auth.html',
        authority: 'https://login.microsoftonline.com/common',
        validateAuthority: true,
        navigateToLoginRequestUrl: false,
    },
    cache: {
        cacheLocation: 'localStorage',
        storeAuthStateInCookie: false,
    },
}

// Create the main MSAL instance
var msalInstance = new msal.PublicClientApplication(msalConfig);

// Login using the same scopes and redirectUri for all environments
msalInstance.loginPopup({ scopes: ['user.read'], redirectUri: 'https://localhost:3000/auth.html' })
    .then(function (response) {
        // Use the same access token for all environments
        var token = response.accessToken;
        console.log(token);
        // Call the API using the same scopes and access token for all environments
        callApi('https://your-web-api.com/api/data', token, ['user.read'])
            .then(function (response) {
                console.log(response);
            })
            .catch(function (error) {
                console.log(error);
            });
    })
    .catch(function (error) {
        console.log(error);
    });

相关内容

热门资讯

黑科技辅助!pokerist有... 黑科技辅助!pokerist有挂(德扑ai智能机器人)果然是有挂(有挂详情)-哔哩哔哩1、任何德州a...
黑科技好友房!aapoker透... 黑科技好友房!aapoker透明挂(wpk ai辅助)素来是真的有挂(有挂教学)-哔哩哔哩1、超多福...
黑科技存在!gg扑克可以赢不了... 黑科技存在!gg扑克可以赢不了(微扑克透牌)一贯是有挂(有挂详情)-哔哩哔哩1、微扑克透牌系统规律教...
黑科技能赢!wepoke计算辅... 黑科技能赢!wepoke计算辅助(wepoke黑科技)往昔是真的有挂(揭秘有挂)-哔哩哔哩是一款可以...
黑科技辅助挂!wepoke a... 黑科技辅助挂!wepoke ai辅助(微扑克如何让系统发好牌)一向是有挂(发现有挂)-哔哩哔哩;小薇...
黑科技了解!德州ai辅助器(微... 黑科技了解!德州ai辅助器(微扑克ai机器人)最初是有挂(有挂解密)-哔哩哔哩1、实时微扑克ai机器...
黑科技脚本!wepoke用模拟... 黑科技脚本!wepoke用模拟器(德扑ai机器人软件开发)原先是真的有挂(有挂神器)-哔哩哔哩1、德...
黑科技脚本!德州ai辅助神器软... 黑科技脚本!德州ai辅助神器软件(aa poker有外挂吗)一贯真的是有挂(果真有挂)-哔哩哔哩1、...
黑科技玄学!约局吧发牌逻辑(w... 1、黑科技玄学!约局吧发牌逻辑(wepoke辅助插件)总是存在有挂(确实有挂)-哔哩哔哩;代表性(透...
黑科技攻略!aapoker透明... 黑科技攻略!aapoker透明(aapoker真的有猫腻吗)从前是真的有挂(有挂教程)-哔哩哔哩;a...