[Vuejs]-Get the Microsoft Graph Token with adal-angular package adal.js authentication context

0๐Ÿ‘

  initialize() {
this.authenticationContext = new AuthenticationContext(config);

return new Promise((resolve, reject) => {
  if (this.authenticationContext.isCallback(window.location.hash) || window.self !== window.top) {
    // redirect to the location specified in the url params.
    this.authenticationContext.handleWindowCallback();
  }
  // try pull the user out of local storage
  let user = this.authenticationContext.getCachedUser();
  // get token
  auth.acquireToken(accessTokenRequest.scopes).then((accessToken)=> {
    if (user) {
      user.token_access_graph = accessToken;
      resolve(user);
    } else {
      this.signIn();
    }
  }).catch(error => {
    console.log('acquireToken error', error);
  })
});

},

Leave a comment