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

相关内容

热门资讯

传递经验!wepoker的辅助... 传递经验!wepoker的辅助器,wepoker能不能透视,攻略教程(有挂透明);亲真的是有正版授权...
三分钟了解!wepoker有没... 三分钟了解!wepoker有没有挂,wpk私人辅助,德州论坛(有挂透明);1分钟了解详细教程(微信 ...
盘点十款!约局吧如何查看是否有... 盘点十款!约局吧如何查看是否有挂,安装不了wepoker,规律教程(有挂软件);大神普及一款德州ai...
必备辅助推荐!hhpoker是... 必备辅助推荐!hhpoker是内部控制吗,红龙poker辅助,揭秘攻略(有挂技巧)1、不需要AI权限...
我来教教你!hhpoker到底... 我来教教你!hhpoker到底可以作弊码,wepoker私人局辅助,教你教程(有挂透视);人气非常高...
终于清楚!wpk透视是真的假的... 终于清楚!wpk透视是真的假的,aapoker透视插件,玩家教你(有挂透视)1、玩家可以在wpk透视...
必备攻略!wepoker轻量版... 必备攻略!wepoker轻量版有透视吗,来玩app破解版,2025新版(有挂软件);1.wepoke...
玩家必备攻略!德州局透视,德州... 玩家必备攻略!德州局透视,德州局脚本,科技教程(有挂攻略);最新版2024是一款经典耐玩的益智游戏,...
盘点一款!wepoker透视底... 盘点一款!wepoker透视底牌脚本,hhpoker有辅助吗,总结教程(有挂教程);玩家必备必赢加哟...
一分钟了解!wepoker有机... 一分钟了解!wepoker有机器人吗,wepoker好友局透视,2025新版教程(有挂透明)1、很好...