不同环境下使用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);
    });

相关内容

热门资讯

德州之星辅助!德扑ai决策软件... 德州之星辅助!德扑ai决策软件,德州wpk果然有挂(详细外 挂教程)是一款可以让一直输的玩家,快速成...
wpk辅助挂!wpK本来真的有... wpk辅助挂!wpK本来真的有挂,wpK果然真的有挂,必赢方法(有挂解密)1、超多福利:超高返利,海...
wepower有外 挂!we-... 1、wepower有外 挂!we-poke有挂(透视辅助)wePoke(一贯真的有挂);详细教程。2...
德扑之星有作弊!德扑人工智能,... 德扑之星有作弊!德扑人工智能,德扑线上其实存在有挂(详细有猫腻教程)1、下载好德扑之星有作弊辅助软件...
攻略教程!wepoke透明真的... 攻略教程!wepoke透明真的(wepokeai代打)wepOke(都是真的有挂);1分钟了解详细教...
wpk德州透视辅助!wpk辅助... wpk德州透视辅助!wpk辅助器小程序,wPK原来真的有挂,详细教程,(有挂技巧)在进入wpk辅助挂...
德扑之星猫腻!德扑计算软件,w... 德扑之星猫腻!德扑计算软件,wepower德州都是真的是有挂(详细数据软件教程)1、金币登录送、破产...
细节方法!wepoke人有挂(... 细节方法!wepoke人有挂(wepoke计算辅助)wepoKe(就是真的有挂)1、很好的工具软件,...
wpk透视辅助测试!wpK一贯... wpk透视辅助测试!wpK一贯真的有挂,wpK的确真的有挂,介绍教程(有挂介绍);1、进入到wpk黑...
德扑起手牌胜率图!德扑之星真破... 德扑起手牌胜率图!德扑之星真破解套路,德州wepower原来是真的有挂(详细ai机器人教程)是一款可...