[Azure AD Mobile Plugin] ADAL issue Microsoft is not defined

Forge Component
(5)
Published on 16 Jan by Pedro Costa
5 votes
Published on 16 Jan by Pedro Costa

Hello, 


I've tried to use this component to enable Azure Active Directory authentication for a mobile app I'm building. I've followed the steps provided here https://github.com/Azure-Samples/active-directory-dotnet-native-multitarget#step-4--register-the-sample-with-your-azure-active-directory-tenant and here https://www.outsystems.com/forums/discussion/44190/azure-ad-mobile-plugin-usage/ however, when attempting to login I'm getting a "Microsoft is not defined" error when the login action hits this step:


Similarly, when I've tried to use the CheckADALPlugin to action to check if the plugin is available, it's giving a "Cannot read ADAL property of undefined" error, presumably when executing this 


Should mention this happens on my android device as well not just in the web emulation.


Any ideas on why that might be the case and a potential fix for it?

Solution

Problem has been fixed. Long story short, I had forgotten you need to regenerate the app in order for the plugin to work.


Otherwise this component works fine still despite the cordova plugin no longer being supported (at least for now).


Thanks for making this azure ad mobile plugin!

Solution

Vlad Almasan wrote:

Problem has been fixed. Long story short, I had forgotten you need to regenerate the app in order for the plugin to work.


Otherwise this component works fine still despite the cordova plugin no longer being supported (at least for now).


Thanks for making this azure ad mobile plugin!

HI Vlad Almasan,

Can you elaborate the solution, even i am getting this same issue-"microsoft is not defined".


Regards,

Mahender Reddy C.


Hi Mahendhar,


First of all, just to make sure, I'll mention that you will get that error if you try to use the ADAL plugin in a browser emulation. It will only work on your device (and, though I've not tested it, probably doesn't work in Outsystems Now either).


If you are indeed on a mobile device, then the cause of the error is likely that after you have added the plugin as a dependency you didn't re-generate the application. A simple update is not enough to enable the plugin's functionality. In order to re-generate the app go in Service Studio on the Native Platforms Tab of your application:


Click on the cog to the right of the version and click Generate App. After that I used the new QR code it generated it to install the app again on my device though I'm not sure if this step is necessary or not.


After doing this you should no longer receive the Microsoft is not defined error.

Vlad Almasan wrote:

Hi Mahendhar,


First of all, just to make sure, I'll mention that you will get that error if you try to use the ADAL plugin in a browser emulation. It will only work on your device (and, though I've not tested it, probably doesn't work in Outsystems Now either).


If you are indeed on a mobile device, then the cause of the error is likely that after you have added the plugin as a dependency you didn't re-generate the application. A simple update is not enough to enable the plugin's functionality. In order to re-generate the app go in Service Studio on the Native Platforms Tab of your application:


Click on the cog to the right of the version and click Generate App. After that I used the new QR code it generated it to install the app again on my device though I'm not sure if this step is necessary or not.


After doing this you should no longer receive the Microsoft is not defined error.


Hi can you tell me how did you implement it?! it keeps giving me a msg that couldn't log in though it retrieve right info.

Abeer ElAssal wrote:

Vlad Almasan wrote:

Hi Mahendhar,


First of all, just to make sure, I'll mention that you will get that error if you try to use the ADAL plugin in a browser emulation. It will only work on your device (and, though I've not tested it, probably doesn't work in Outsystems Now either).


If you are indeed on a mobile device, then the cause of the error is likely that after you have added the plugin as a dependency you didn't re-generate the application. A simple update is not enough to enable the plugin's functionality. In order to re-generate the app go in Service Studio on the Native Platforms Tab of your application:


Click on the cog to the right of the version and click Generate App. After that I used the new QR code it generated it to install the app again on my device though I'm not sure if this step is necessary or not.


After doing this you should no longer receive the Microsoft is not defined error.


Hi can you tell me how did you implement it?! it keeps giving me a msg that couldn't log in though it retrieve right info.

HI Abeer,

There are couple of things need to be considered.

1. you can test AD connectivity in mobile only since ADAL plugin uses cordovan plugin which runs in mobile itself.

2. Do the same as mentions in ADAL plugin demo (https://www.outsystems.com/forums/discussion/44190/azure-ad-mobile-plugin-usage/). Don't create secrete key in Azure. Secrete key will be useful for web api type applications.

3. Enabling access also important. Don't enable all the accesses.

4. Keep console.log or alerts in ADAL plugin java-script functions to track where is the issue.


Regards,

Mahender Reddy C


Mahendhar wrote:

Abeer ElAssal wrote:

Vlad Almasan wrote:

Hi Mahendhar,


First of all, just to make sure, I'll mention that you will get that error if you try to use the ADAL plugin in a browser emulation. It will only work on your device (and, though I've not tested it, probably doesn't work in Outsystems Now either).


If you are indeed on a mobile device, then the cause of the error is likely that after you have added the plugin as a dependency you didn't re-generate the application. A simple update is not enough to enable the plugin's functionality. In order to re-generate the app go in Service Studio on the Native Platforms Tab of your application:


Click on the cog to the right of the version and click Generate App. After that I used the new QR code it generated it to install the app again on my device though I'm not sure if this step is necessary or not.


After doing this you should no longer receive the Microsoft is not defined error.


Hi can you tell me how did you implement it?! it keeps giving me a msg that couldn't log in though it retrieve right info.

HI Abeer,

There are couple of things need to be considered.

1. you can test AD connectivity in mobile only since ADAL plugin uses cordovan plugin which runs in mobile itself.

2. Do the same as mentions in ADAL plugin demo (https://www.outsystems.com/forums/discussion/44190/azure-ad-mobile-plugin-usage/). Don't create secrete key in Azure. Secrete key will be useful for web api type applications.

3. Enabling access also important. Don't enable all the accesses.

4. Keep console.log or alerts in ADAL plugin java-script functions to track where is the issue.


Regards,

Mahender Reddy C



Hi Mahendhar,

thanks for your reply, here's what I did:



And for configuration and redirect url I used these, note that I used same of my app link in the azure app redirect url, and I didn't generate secret key and generated app and testing on mobile:


For login I used these:


when debugging it gets data right so I thing wrong thing is in dologin, or even when it redirect link. can you help me with checking configuration please?!

thanks,

Hi Abeer ElAssal,


The steps I followed to implement the plugin are described in detail in Pedro Costa's post here: https://www.outsystems.com/forums/discussion/44190/azure-ad-mobile-plugin-usage/

and in steps 3-4 here: https://github.com/Azure-Samples/active-directory-dotnet-native-multitarget#step-4--register-the-sample-with-your-azure-active-directory-tenant


On top of this you have to set up the Client_IdentityProvider site property for your installation of the ADAL Plugin with information specific to your Azure Directory.


If you've done all this and are still getting an error, then we'll need more detailed information about where in the process it happens and what the error is to help you


It might also be a good idea to create a new support thread in the component's forge section for your specific problem and maybe the component's creators can help.


What I have to put on Client_IdentityProvider property?

Walace Morais wrote:

What I have to put on Client_IdentityProvider property?

Hi Walace,

You can use the debugger to get the value of LocalADALUser.IdentityProvider, after this, fill the Client_IdentityProvider property correctly.

Or, change the site.Client_IdentityProvider for LocalADALUser.IdentityProvider.


Regards,

Pedro