ADAL.js - Obtaining Microsoft Graph Access Token with id_token

后端 未结 2 2136
再見小時候
再見小時候 2021-01-13 08:22

I am attempting to integrate Azure AD login and Graph API into my angular2 website.

I have successfully implemented an ADAL login and redirect, built around a useful

2条回答
  •  春和景丽
    2021-01-13 08:51

    I found a solution to my problem.

    I was using the wrong token. I had to acquire a token specifically for Graph API. This meant I would have to first log in and then call this.context.acquireToken() like below:

    this.context.acquireToken("https://graph.microsoft.com", function (error, id_token) {
    
        if (error || !id_token) {
            console.log('ADAL error occurred: ' + error);
        } 
        else {
                this.graphAccessToken = id_token;
                //Call graph API
        }
        }.bind(this)
    );
    

    It seems like it's essential that this process have 2 calls. Maybe someone can shed some light on whether I can immediately obtain a token with scope for the Graph API on login. Perhaps by setting required permissions for the app in Azure AD.

提交回复
热议问题