我正在尝试使用使用authenticationContext创建的'adal-angular/lib/adal.js' package来获取microsoft graph资源的令牌。
错误:
需要
用户登录。此时console.log(:error在这里)
依赖关系:
"adal-angular": "^1.0.18",
"vue": "^2.6.12",
"vue-adal": "^1.3",代码:
initialize() {
this.authenticationContext = new AuthenticationContext(config);
return new Promise((resolve, reject) => {
if (this.authenticationContext.isCallback(window.location.hash) || window.self !== window.top) {
this.authenticationContext.handleWindowCallback();
this.graphToken(this.authenticationContext);
let user = this.authenticationContext.getCachedUser();
resolve(user);
} else {
let user = this.authenticationContext.getCachedUser();
if (user) {
resolve(user);
} else {
this.signIn();
}
}
});
}
graphToken(authctx) {
authctx.acquireToken('https://graph.microsoft.com', function (error, token) {
console.log(error + ":::error is here");
console.log(token + "graph token");
})
}发布于 2022-01-13 13:11:40
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);
})
});},
https://stackoverflow.com/questions/69493398
复制相似问题