I am using 'adal-angular4' library to authenticate to dynamic 365 CRM online.
I set up azure application according to https://github.com/Azure-Samples/active-directory-angularjs-singlepageapp.
My code for authentication is almost the same as on example https://github.com/benbaran/adal-angular4-example.
My home component model:
config: any = { tenant: '', clientId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' }; constructor(private adalService: Adal4Service) { this.adalService.init(this.config); this.adalService.handleWindowCallback(); // Check if the user is authenticated. If not, call the login() method if (!this.adalService.userInfo.authenticated) { this.adalService.login(); } console.log('token: ' + this.service.userInfo.token); }
Here I successfully get token and all user info.
But when I tried to acquire/verify my token for dynamic 365 CRM I always get error:
"Token renewal operation failed due to timeout"
My code for acquiring token:
this.adalService.acquireToken('https://comdynamics365en.crm4.dynamics.com')
.subscribe(data => {
console.log(data); // never get this
},
error => {
console.log("Error while AcquireToken. Error Info: " + error);
})
I do not know what I am doing wrong ?