javascript - ADAL JS - Acquire token: Token Renewal Operation failed due to timeout -
i'm working in order leverage usage of ad authentication , authorization of several applications, , i'm studying how implement said process.
this web-browser web-application flow.
i create authenticationcontext instance , use sign in, , functions normally. (code organization simplified demo purposes)
this.adal = new authenticationcontext({ tenant: this.tenantid, clientid: this.clientid, redirecturi: this.redirecturi, callback: this.logincallback, popup: true }); this.adal.login();
it when try acquire token behaviour becomes fishy. relevant application's registry in ad has permission "sign in , read user profile" on microsoft graph api.
this.adal.acquiretoken("https://graph.microsoft.com", function(error, token) { console.log(error); console.log(token); });
the error written console follows: "token renewal operation failed due timeout"; whilest token written null object. brief @ "network" tab while inspecting page chrome reveals such resource:
authorize?response_type=token&client_id=xxxxx&resource=xxxxx&redirect_uri=http://localhost:8080(.....)
the status said resource 302.
got clues? thanks!
ok.. seems i've figured out, little article click article , click cool info
i've replaced following bit of code, in login callback
this.adal.acquiretoken("https://graph.microsoft.com", function(error, token) { console.log(error); console.log(token); });
for this:
var cachedtoken = this.adal.getcachedtoken(client_id_goes_here); if (cachedtoken) { this.adal.acquiretoken("https://graph.microsoft.com", function(error, token) { console.log(error); console.log(token); }); }
and add line of code function run after acquiretoken method redirects page:
this.adal.handlewindowcallback();
hope helpful others run issue!
wiki
Comments
Post a Comment