2
votes

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 ?

1
Never ever provide private keys from azure here. Are you providing the tenant?Fals
No i did not provide tenant I thought it is not obligatory.Milos
I set up "Multi-tenanted" option to "No", it means only one tenant. I do not need to specify tenant, if I understand it well.Milos
I'm following the same example code using a single tenant and get the same problem. I can authenticate to azure AD fine but trying to access a linked API with acquireToken gives me "Token renewal operation failed due to timeout" :(Michael Harper

1 Answers

0
votes

I got rid of the "Token renewal operation failed due to timeout" by changing this.adalService.acquireToken('https://comdynamics365en.crm4.dynamics.com')

to

this.adalService.acquireToken('{application ID }') (the application ID is listed in Azure, no idea why the ID works and the URI doesn't)

Hope this helps