AzureAD / azure-activedirectory-library-for-js

The code for ADAL.js and ADAL Angular has been moved to the MSAL.js repo. Please open any issues or PRs at the link below.
https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/maintenance/adal-angular
Apache License 2.0
627 stars 373 forks source link

AuthenticationContext is not a constructor #851

Closed abu-wizata closed 4 years ago

abu-wizata commented 5 years ago

I'm submitting a...


[X] Bug report  

Browser:

Library Name & Version

Current behavior

"AuthenticationContext is not a constructor." //import { AuthenticationContext } from 'adal-angular'; //Both of these have same issue

import * as AuthenticationContext from 'adal-angular';

// The AuthenticationContext needs to be globally available for adal-angular

window['AuthenticationContext'] = AuthenticationContext; //Issue occurs with or without this line

/ This is pulled directly from the Readme.md example, and should work. /

window.config = { clientId: '[Enter your client_id here, e.g. g075edef-0efa-453b-997b-de1337c29185]',

   popUp: true,

   callback : callbackFunction

};

//this.context = new AuthenticationContext(config);

var authContext = new AuthenticationContext(config);

Expected behavior

No error.

Minimal reproduction of the problem with instructions

Install node.js. Install adal-angular. Setup these lines of code shown directly in the adal-angular read me. See error.

neptunecentury commented 5 years ago

I am getting this same problem. I import the AuthenticationContext from 'adal-angular' and see the error message when I try to instantiate it.

If I use this: import adal from "adal-angular"; window.config = { ... }; // Config omitted var authContext = new adal(window.config);

It works. But, it seems it's not using version 2 of the API, because I can't sign in with my personal account, but my work office 365 account works.

On a side note though, once I sign in, it tells me the return URL doesn't match. Not sure what I need to set it to since I've already checked all the suggested URLs. This is for an electron app

jmckennon commented 4 years ago

The documentation for adal js should be updated and working for this issue, per the wiki page here.

It is also correct that adal js only supports the v1 API. msal js supports both v1 and v2. We highly recommend using msal over adal.

All current authentication work from Microsoft is delivered through the msal js library here. adal js is still supported only for security fixes. We recommend moving to msal js for any advanced feature requests and bugfixes.