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

相关内容

热门资讯

一分钟揭秘!扑克之星辅助,we... 一分钟揭秘!扑克之星辅助,wepoker透视脚本免费下载,爆料教程(有挂透明);玩家必备必赢加哟《1...
透视系统!wepoker破解器... 透视系统!wepoker破解器(透视)总是是有挂(详细辅助细节揭秘)1、ai辅助优化,发牌逻辑科技护...
一分钟秒懂!哈糖大菠萝辅助器,... 一分钟秒懂!哈糖大菠萝辅助器,hhpoker破解工具,2025版教程(有挂方法);支持2-10人实时...
透视免费!德州真人透视脚本(透... 透视免费!德州真人透视脚本(透视)一贯真的有挂(详细辅助爆料教程)1、这是跨平台的黑科技,在线的操作...
玩家必看教程!wepoker私... 玩家必看教程!wepoker私人局俱乐部怎么进,佛手在线大菠萝智能辅助器,透视教程(有挂技巧)准备好...
透视教程!菠萝德州透视脚本(透... 透视教程!菠萝德州透视脚本(透视)确实真的有挂(详细辅助详细教程)1、机器人多个强度级别选择2、发牌...
一分钟秒懂!wepoker辅助... 1、一分钟秒懂!wepoker辅助器安装包,wepoker辅助器安装包,wpk教程(有挂攻略);详细...
透视线上!wepoker脚本(... 透视线上!wepoker脚本(透视)一贯是真的有挂(详细辅助攻略教程);wepoker脚本是一种具有...
关于!wepoker游戏下载,... 1、关于!wepoker游戏下载,aapoker破解侠是真的吗,可靠技巧(有挂软件)(UU poke...
透视软件!wepoker底牌透... 透视软件!wepoker底牌透视(透视)好像存在有挂(详细辅助细节揭秘)1、每一步都需要思考,不同水...