Manos Pasgiannis
Manos Pasgiannis

Reputation: 1783

Angularjs doesn't authenticate with Azure Active Directory

I have an angularjs web application that uses Azure Active Directory for authentication. The Web Api that the application uses, authenicates without any errors.

For client-side authentication I am using adal.js and adal-angular.js. When i try to visit any page in my app, authentication fails and prints the following messages in the console

The returned id_token is not parseable.
Route change event for:/
Start login at:https://localhost:44308/#
Navigate url:https://login.windows.net/myapp.onmicrosoft.com/oauth2/authorize
Navigate to:https://login.windows.net/myapp.onmicrosoft.com/oauth2/authorize
TypeError: Cannot read property 'data' of undefined

I have followed this tutorial.

Does anyone know what is going on or how can I debug this?

Upvotes: 2

Views: 1739

Answers (2)

Manos Pasgiannis
Manos Pasgiannis

Reputation: 1783

The error was in the adal.js library when the token which didn't decode correctly utf-8 characters.

An updated version of the library with the bug fix will be available soon.

Upvotes: 3

Noel
Noel

Reputation: 3526

It's tough to answer without seeing a code sample. If you're using promises, you need to handle the case if the promise is rejected. You probably have something like this:

    myAuthService.authenticate(...).then(function(data){
       //this handles the successful call.
    });

What you need to see the error is something like this:

        myAuthService.authenticate(...).then(function(data){
           //this handles the successful call.
        }, function(e){
           //this handles the error case
           alert('errror.  inspect this.arguments');
});

You should post the code that is throwing the error.

Upvotes: 1

Related Questions