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);
})
});
},
Source:stackexchange.com