Giter Club home page Giter Club logo

azure-activedirectory-library-for-cordova's Introduction

This library has been archived

If you really wish to view the archived library, please switch to the archive branch. This code is no longer maintained and functionality is not guaranteed.

azure-activedirectory-library-for-cordova's People

Contributors

alsorokin avatar brandwe avatar danyoel avatar eekay avatar jmprieur avatar joshgav avatar kaiwalter avatar khalidawwad avatar matrosov-nikita avatar nikhilkh avatar okulygin avatar riknoll avatar rohitnarula7176 avatar sgrebnov avatar tmct avatar vladimir-kotikov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-activedirectory-library-for-cordova's Issues

VS2015 Codova tool build failed in iOS device when adding ADAL plugin

The issue is as below (if you build using emulator, you will only receive a warning)
Error The file “ADALiOS.entitlements” couldn’t be opened because there is no such file.: (null) BlankCordovaApp7 c:\users\chunyih\documents\visual studio 2015\Projects\BlankCordovaApp7\BlankCordovaApp7\MDAVSCLI 1

How to fix (work around, need plugin code fix)
Go to the project in Mac and open the remote build project using XCode, go to the build setting and change the entitlement setting from "/MOA/Resources/ADALiOS.entitlements" to "MOA/Resources/ADALiOS.entitlements".

[Proposal] expose api to enable/disable broker app

As per discussion in #46:
If application is not configured to support broker app (requires special redirect uri format) and company app is installed on Android then the plugin is unable to pass authentication. It will be great to have a way to skip broker.

Alternatives:

  1. Introduce config.xml setting, for example skipBroker (true/false)
  2. Expose this as JS api: Microsoft.ADAL.AuthenticationSettings.setSkipBroker(true/false)
  3. Automatically detect based on redirect uri scheme ("msauth://", etc - not sure this is possible)
  4. Disable broker support at all.

TODO:

  1. Consistency across the platforms (review if this is required/supported on ios and windows)
  2. Should be enabled/disabled by default?

Issue mapping displayName from context on Windows Phone 8.1

The line below in the ADALProxy returns a WinJS error causing a failure.

displayName = mapUserUniqueIdToDisplayName(context, userId);

I am writing a Windows Universal Phone App on Windows Phone 8.1 Update 2.

WinRTError: No such interface supported

System.InvalidCastException: Specified cast is not valid.
at System.StubHelpers.InterfaceMarshaler.ConvertToNative(Object objSrc, IntPtr itfMT, IntPtr classMT, Int32 flags)
at mapUserUniqueIdToDisplayName

How to use Company Active Directory?

I am new to Active Directory and we have a requirement that is we need to consume client's active directory in mobile how to move about. Can you please explain the steps to be followed in order to consume active directory in mobile.

Thanks

ADAL native libraries are out of date

ADAL Android appears to reference 1.1.1 while 1.1.12 is current. I suspect iOS and Windows are also out of date.

We should update to the latest versions of the native libraries for the plugin given it entirely depends on the underlying native implementations of the ADAL libraries.

acquireTokenAsync never returns

When acquireTokenAsync excecutes, it shows the Microsoft Login Page and I can enter the credentials. After clicking on the login button, nothing happens and the method never returns anything: There is no success or failure callback being called.
What could be the issue?

Issue signing in with Personal Account

I have an Azure Tenant set up from my MSDN account which is [email protected]
My tenant was created automatically when I signed up for my Azure benefits as namecompany.onmicrosoft.com

  • I also have an Office 365 account (Org ID) with the same email as my Personal account.
  • When I run the default sample it will redirect me to the microsoft login.
  • I type my email and focus to the password field.
  • At this point I get the standard "is this an Org ID or Personal account.
  • I choose Personal account since my personal account is what I use to log into the Azure Management portal.
  • It redirects me to the login for personal accounts.
  • I type my password and successfully authenticate.
  • It redirects me back to my native app and the authResult from the promise has null for accessToken and userInfo objects.

I can successfully login and get a token if I use a new user that I create on the tenant [email protected]

The authResult for the response looks like:
{"expiresOn": null, "isMultipleResourceRefreshToken": false, "statusCode": "Failed", "userInfo": null }

This is hitting the success handler in promise.

"pre_package" hook is deprecated

"pre_package" hook is deprecated and will be removed in next Windows platform versions. Please use "after_prepare" (or another appropriate hook)

ADAL not working in Arabic Device Language Android

Hello ,
i cannot login with ADAL when Device Language is Arabic , plugin always delete authentication token and login page open again . kindly note that same code works fine in Android when device language is English.

Permissions needed for broker?

Found the following in LogCat when authenticating.

607-19355/com.microsoft.services.sample.cordovaApp W/BrokerProxy﹕ DEVELOPER_BROKER_PERMISSIONS_MISSING:2015-04-28 04:52:22-b45b17ac-6b97-4901-a360-a30222614f6d-Broker related permissions are missing for GET_ACCOUNTS, MANAGE_ACCOUNTS, USE_CREDENTIALS ver:1.1.1 04-27 21:52:22.503 18

Looks from this that more permissions need to be set in the AndroidManifest by the plugin to utilize the broker. When I added those permissions to plugin.xml the error went away.

Cannot compile ios target with adal cordova library and space in config.xml's name property

Tooling used:
Macbook pro with OS X Yosemity 10.10.3, Cordova CLI 5.0.0, NPM 2.7.4, Node v0.10.28
Xcode 6.3.1, Command Line Tools (OS X 10.10) for Xcode 6.3.1

Steps to reproduce:

  • create new project with
    $ cordova create adalbuilderrortest com.example.adaltest 'Adal Testapp'
  • go to adalbuilderrortest/www
  • add plugin via
    $ cordova plugin add cordova-plugin-ms-adal
  • add platform ios via
    $ cordova platform add ios
  • try to build and/or emulate ios target
    $ cordova build ios (or cordova emulate ios)

The resulting error is:
xcodebuild[30309:244944] CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 513. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug.

Currently there are two "tests" to see if one can get the ios target building again:

  1. removing the adal plugin (not an option for me)
  2. removing the space between Adal and Testapp in the config.xml's > widget > name property

I've been inspecting the hook scripts and other stuff but cannot really find a cause for this myself.
Hope you can check this out!?

acquireTokenSilentAsync fails to return a token after a successful login

We've created a sample application following Integrate Azure AD with an Apache Cordova app and replaced the AAD app configuratin with our own.

We are able to get a working token by calling context.acquireTokenAsync and no errors are thrown. After a successful login we expect that context.acquireTokenSilentAsync should return a token without showing an UI. However, this method throws the following error

Error: The user credentials are need to obtain access token. Please call the non-silent acquireTokenWithResource methods

We also observed, that context.tokenCache.readItems() always returns an empty array, even if the user has logged in before.

We've tested this on iOS.

Exception when using ADAL cordova on a encrypted android phone

I am developing a cordova app that uses ADAL cordova and requires a service from a corp network (MSFT corp network). ADAL cordova works using an emulator, but on a real device (which requires encryption to access the corp network) ADAL cordova is giving me an exception. The following is the exact error:

E/PluginManager(18227): Uncaught exception from plugin
E/PluginManager(18227): java.lang.ClassCastException: com.microsoft.aad.adal.AuthenticationContext$1 cannot be cast to com.microsoft.aad.adal.DefaultTokenCacheStore
E/PluginManager(18227): at com.microsoft.aad.adal.CordovaAdalPlugin.readTokenCacheItems(CordovaAdalPlugin.java:165)
E/PluginManager(18227): at com.microsoft.aad.adal.CordovaAdalPlugin.execute(CordovaAdalPlugin.java:83)
E/PluginManager(18227): at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:84)
E/PluginManager(18227): at org.apache.cordova.PluginManager.exec(PluginManager.java:147)
E/PluginManager(18227): at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
E/PluginManager(18227): at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:40)
E/PluginManager(18227): at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
E/PluginManager(18227): at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:53)
E/PluginManager(18227): at android.os.Handler.dispatchMessage(Handler.java:102)
E/PluginManager(18227): at android.os.Looper.loop(Looper.java:145)
E/PluginManager(18227): at android.os.HandlerThread.run(HandlerThread.java:61)

And the following is my code:
$scope.context = new Microsoft.ADAL.AuthenticationContext(authority);

$scope.context.tokenCache.readItems().then(function (items) {
  if (items.length > 0) {
    authority = items[0].authority;
    $scope.context = new Microsoft.ADAL.AuthenticationContext(authority);
  }

  // Attempt to authorize user silently
  $scope.context.acquireTokenSilentAsync(resourceUrl, appId)
  .then(onAADSuccess, function () {
  // We require user cridentials so triggers authentication dialog
  $scope.context.acquireTokenAsync(resourceUrl, appId, redirectUrl)
 .then(onAADSuccess, function (err) {
    });
  });
});

Any help would be appreciated!

implementing the plugin in Ionic

Hello,
I am trying to implement it in the Ionic framework. I can't get it to work - after installation, I get the "Error: Microsoft is not defined". I suppose I have to inject some dependency to the controller, but what exactly?

Building android version of the sample from repo fails: cannot resolve all dependencies

I updated to the latest cordova stuff:

  • npm -v: 1.3.8
  • node -v: v0.10.28
  • cordova -v: 5.0.0
  • cordova platform: Installed platforms: android 4.0.0, ios 3.8.0
  • cordova plugin:
    • cordova-plugin-ms-adal 0.5.0 "ADAL for Cordova"
    • cordova-plugin-whitelist 1.0.1-dev "Whitelist"

When i follow the steps as by docs on the github Readme:

  • clone repo
  • create project with sample www
  • go to ADALSample dir
  • add platform android
  • cordova run android

This gives me (cordova build android gives this as well) the following build issue:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_debugCompile'.
   > Could not find any version that matches com.android.support:support-v4:[18,).
     Searched in the following locations:
         https://repo1.maven.org/maven2/com/android/support/support-v4/maven-metadata.xml
         https://repo1.maven.org/maven2/com/android/support/support-v4/
     Required by:
         :android:unspecified > com.microsoft.aad:adal:1.1.1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Running the iOS version of the sample app DOES work so it seems this is android version related...

Windows Phone 8.1 build fails to deploy from Visual Studio.

When using version 0.6.2 of the plug-in I am seeing an error "Error : DEP6810 : MdilXapCompile.exe failed with error code 2001" when I try to deploy to Windows Phone 8.1. All other platforms seem to deploy correctly (including Windows 10 phone). I am using VS2015 with the latest update of the tools for Apache Cordova and the error is in the main project when I try to deploy to phone.

If I drill down to the generated VS solution under platforms/windows and deploy to the device from that solution (targeting Any CPU) it deploys and works correctly on the device.

If I use version 0.6.0 of the plug-in (the version retrieved by the VS tooling as a "Core" plugin) the project deploys to the device but the function acquireTokenAsync never invokes its promises and so it doesn't work, which may be expected behaviour with this older version.

Error in build

Error 3 El comando ""C:\Users\borja.alvarez.ELNR\AppData\Roaming\npm\node_modules\vs-mda\vs-cli" build --platform "Android" --configuration "Debug" --projectDir . --projectName "BlankCordovaApp1" --language "es-ES" --buildServerUrl "" --buildTarget "AndroidDevice"" salió con el código 8. C:\Users\borja.alvarez.ELNR\AppData\Roaming\npm\node_modules\vs-mda-targets\Microsoft.MDA.targets 99 5 BlankCordovaApp1
Error 2 H:\HYBRID\BlankCordovaApp1\BlankCordovaApp1\bld\Debug\platforms\android\cordova\build.bat: Command failed with exit code 2 H:\HYBRID\BlankCordovaApp1\BlankCordovaApp1\EXEC 1 1 BlankCordovaApp1

When i add plugin to project it makes the build fail, ihavent found any solution, any idea?

User needs to login again after the token expires on Android

As reported here:

https://azure.microsoft.com/en-us/documentation/articles/active-directory-devquickstarts-cordova/#comment-2529291577

Hi there. I managed to get this working, but after the token expires the user needs to login again. So I went searching and found that this is probably due to not using a refresh token instead of an access token. So I found this https://msdn.microsoft.com/en-us/library/azure/dn645542.aspx which describes the flow for getting a refresh token, but I'm not quite sure on how to implement this using the library. According to the Android page (https://azure.microsoft.com/en-us/documentation/articles/active-directory-devquickstarts-android/) calling acquireTokenSilentAsync should refresh the token and I understood that refresh tokens last 14 days. But that's not working within my app, I need to login again quite often.

Failure to Load Resource - running plugin with Ionic

Oops, for got to add the problem here:
When I pull up the debugger it is complaining that this file is missing.
Project seems to run fine without it , but it would be nice to get the error resolved.

Ideas ?, BTW thank's for the awesome plugin . I have it running in Ionic without any problems.

file:///Users/zzzzz/Library/Developer/CoreSimulator/Devices/DF4F351E-3651-4D91-BB86-763DD58A5856/data/Containers/Bundle/Application/B6B51E16-89E3-48BF-88A8-3936B5D62DE1/InsertManagement.app/www/plugins/com.microsoft.aad.adal/www/utility.js.map

Token expiring in less then 30 seconds

I am using this plugin and successfully created authentication context and acquiring token. But the token is expires in just seconds. How can I get the token which is valid for few hours or minutes.
I am using latest Cordova 5.4.1 version

Use the VS2013+ Tools to Build

More of a heads up than an issue as it cost me some time.

Once you have done "cordova platform add windows" (avoid wp8), if you are in a normal command line it will use VS2012 if you will get MakePri "Schema Validation Failed" and so on .... took me a while to figure this out.

Just open a VS 2013 command prompt (not that it will say 2012 in the path but ignore that).

It should now build properly.

is this repo the source for cordova-plugin-ms-adal

in the https://github.com/Azure-Samples/active-directory-cordova-multitarget sample it outlines using this repo, i.e.
git clone https://github.com/AzureAD/azure-activedirectory-library-for-cordova.git [d:\src\repos]azure-activedirectory-library-for-cordova, as source for enabling adal cordova plugin in vs15upd1 cordovaUpd5, aka taco, project environment.

I'm finding that when i visit vs15upd1 cordovaUpd5, aka taco, project environment config.xml | plugins there is now an "adal for cordova [ / cordova-plugin-msadal ]" entry that comes from https://www.npmjs.com/package/cordova-plugin-ms-adal.

is this git repo the source for that published cordova plugin offering or are they separate efforts and if so which one is the supported story i should be using?

Weird authflow issue on sample

I've built the sample (https://github.com/Azure-Samples/active-directory-cordova-multitarget) and tried it. When I perform a search, the login windows pops up. I choose "login with a Microsoft account" because I'm using my Microsoft account for Azure. The other login screen appears and I enter my credentials, after which it asks for the verification code on my phone. Now after what I believe to be a successful login, I'm returned to the corporate login screen again. I can choose "Microsoft account" again and the whole process endlessly repeats.

I'm lost in why this happens as there is so little to go on, I don't see any error messages. Any idea?

the afterinstall script for android refers to old minimum sdk

The script afterPluginInstall-android.js sets the android:minSdkVersion to 14 for the manifest file.
This in its turn triggers the build to include the android-support-v4.jar file.

When using a library that depends on the newer v13 support jar this will create "Multiple Dex included" issues like:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;

(see issues with Pushplugin like phonegap-build/PushPlugin#492)

Setting the minimum to sdk 18 or higher fixes this and lets the build continue again. could we crank this number up so issues in conjunction with popular plugins like Pushplugin wont break the build?

Authentication not working

I'm having issues doing authentication in the first place. Library redirects to Azure, I log in using MSA and then get returned back but according to the library the authentication failed (which it didn't).

Referring to http://stackoverflow.com/questions/35078656/cordova-app-using-angular-adal?noredirect=1#comment58272778_35078656 for detail. I just cannot get it to work, not even the sample provided. Library keeps saying my login attempts are unsuccessful even though peeking in the responses from Azure reveals solid auth tokens being returned over the line. Tried both Android and Windows Phone, results are roughly the same although error messages differ.

Uncaught SecurityError: Failed to execute 'openDatabase' on 'Window': Access to the WebDatabase API is denied in this context.

I have this project where Users can log in using Azure AD authentication, the app retrieves the token, but, it seems that opening the authentication window changes the app's window object in some way and after that a cannot navigate to any other page in my app because when I try to open database, this error occurs : "Uncaught SecurityError: Failed to execute 'openDatabase' on 'Window': Access to the WebDatabase API is denied in this context."

Windows 10 mobile: AuthenticationContext: type is not constructible

When running on Windows 10 mobile (a 950XL), everything is working fine if debugging with Visual Studio, but if running the app without debug (just launching it on the device), any call to ADAL results in an error "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext: type is not constructible"

Does it work with ADFS 2.0

Hi,
I need to secure a cordova app (IOS & Windows 10 platform) with ADFS 2.0. I want to know if this plugin support this version ? I think not, but could you confirm ?

Running into 'class not registered' error when running the sample

I followed the instructions at https://github.com/AzureAD/azure-activedirectory-library-for-cordova and tried to run the sample https://github.com/AzureAD/azure-activedirectory-library-for-cordova/tree/master/sample. However in the UI I always run into this:

image

On debugging this a little further I am noticing the following exception at this line: https://github.com/AzureAD/azure-activedirectory-library-for-cordova/blob/master/src/windows/ADALProxy.js#L65

WinRTError: Class not registered
at ADALProxy.createAsync (ms-appx://io.cordova.hellocordova/www/plugins/cordova-plugin-ms-adal/src/windows/ADALProxy.js:65:17)\n   at module.exports (ms-appx://io.cordova.hellocordova/www/cordova.js:874:13)\n   at cordovaBridge.executeNativeMethod (ms-appx://io.cordova.hellocordova/www/plugins/cordova-plugin-ms-adal/www/CordovaBridge.js:41:9)\n   at AuthenticationContext.createAsync (ms-appx://io.cordova.hellocordova/www/plugins/cordova-plugin-ms-adal/www/AuthenticationContext.js:57:5)\n   at app.createContext (ms-appx://io.cordova.hellocordova/www/js/index.js:81:9)"

I'm very much blocked on this issue. Will totally appreciate if you could give any pointers.

Improve documentation in repo home

  • Main example should be complete, you should be able to copy/paste it and it should work
  • Update Supported platforms section (+Windows 10)
  • Api (methods description/signatures)
  • acquireTokenAsync prompt behavior (Always vs Auto which is used by native components)
  • Recommendations for signout

UserInfo example

Hi,
After authenticating I want to access various information about the authenticated user. Can you give any examples of how to do this?

In ADALJS, it seems to set up a "UserInfo" object under the root scope which is accessible in my html templates for stuff like "ng-show="userInfo.isAuthenticated".

Is it possible to do the same with ADAL for Cordova?

I can see there is a UserInfo.js file ... but can't figure out how its used.

acquireTokenAsync always prompting for sign-on

In AuthenticationContext.js the comment states that the function

...Acquires token using interactive flow if needed. It checks the cache to return existing result
if not expired. It tries to use refresh token if available. If it fails to get token with
refresh token, it will remove this refresh token from cache and start authentication.

When I test this it always requests authentication. If I follow the code path on, say, Windows 8.1 I notice it sets Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior.always in ADALProxy.js. Also in e.g. CordovaAdalPlugin.java, it sets PromptBehavior SHOW_PROMPT_ALWAYS = PromptBehavior.Always. I suggest that in both cases the prompt behaviour should be set to auto. If I modify ADALProxy.js and set PromptBehavior.auto it seems to work as expected.

There is an option to set
<preference name="adal-use-corporate-network" value="true" /> in the plug-in config that should change the behaviour, but that is not the default (and I think applies to the intranet scenario only). I assume the intention was that the library takes care of cached credentials and refresh tokens without the caller having to explicitly check the cache, If not, we should change the documentation of the method to make this clear.

Failed to login if on a company portal enrolled android device.

Hi,

I tried the plugin on a company portal enrolled android device, but AAD login failed with error:

V/BasicWebViewClientonPageStarted(25118): 2016-02-25 09:02:09-null-page is started with the url urn:ietf:wg:oauth:2.0:oob?code=AAABAAAAiL...&state=YT1odHRwczovL2xvZ2luLndpbmRvd3MubmV0L2NvbW1vbiZyPWh0dHBzOi8vbWFuYWdlbWVudC5jb3JlLndpbmRvd3MubmV0Lw&session_state=a3c44a8f-555c-453e-b9b1-5411bf2618a2 ver:1.1.12
ERROR_WEBVIEW:2016-02-25 09:02:09-null-Webview received an error. Errorcode:-10 net::ERR_UNKNOWN_URL_SCHEME ver:1.1.12

Seems AAD authentication passed but the redirect url could not recognized? I tried to uninstall company portal then it works fine. Any ideas?

B.t.w. How can I change settings in AuthenticationSettings in cordova?

Thanks

Request for help silent login cordova app start page

I'm building a small app to test adal cordova and wanted to create an app with start page with button to login in Azure, but also silent sign-in when token is already in cache. I took the Cordova-Calendar-App-Code-Sample with O365 authentication as basis for my app.

The button with login works fine, but I don't get the silent login, triggered by the controller at startup working. I get the error:

ReferenceError: Microsoft is not defined
    at Object.login (file:///android_asset/www/app/service-AAD.js:42:35)
    at signInCtrl.vm.silentsignin (file:///android_asset/www/app/auth/sign-in-ctrl.js:24:23)

==> service-AAD.js: authContext = new Microsoft.ADAL.AuthenticationContext(authority);

I thing that the button click login works because of the $scope, and that the silent sign-in is not working because of the 'var vm = this' and missing scope to find the ADAL plugin?

Unfortunately I don't know how to solve this, i hope you can give me a helping hand.

sign-in-ctrl.js

(function () {
    'use strict';

    angular.module('appAAD').controller('signInCtrl', ['$scope', '$state', 'appAADapi', signInCtrl]);

    function signInCtrl($scope, $state, appAADapi) {

        var vm = this;

        // Callback after successful login
        var onlogin = function (reason) {
            if (typeof reason != 'undefined') {
                if (reason.statusCode === 'Succeeded') {
                    // Navigate to main page when sign-in was successful.
                    $state.go('app');
                }
            }
        };

       // $scope.signIn is called by button on sign-in.html
       // This works
        $scope.signIn = function () {
            appAADapi.login(onlogin);
        };

       // This does not work, error:
       // ReferenceError: Microsoft is not defined
        vm.silentsignin = function () {
            appAADapi.loginSilently(onlogin);
        }

        // Try to sign silently on app startup
        // if not successful, then show login button
        vm.silentsignin();

    }
})();

service-AAD.js

(function () {
    'use strict';
    angular.module('appAAD').factory('appAADapi', [appAADapi]);

    function appAADapi() {

        var authContext;
        var authority = "https://login.windows.net/common",
            redirectUri = {redirectUri}",
            resourceUri = "https://graph.windows.net",
            clientId = "{clientId}",
            graphApiVersion = "2013-11-08";


        function loginSilently(callback) {
            if (!authContext) {
              authContext = new Microsoft.ADAL.AuthenticationContext(authority);

            }
            authContext.tokenCache.readItems().then(function (items) {
                if (items.length > 0) {
                    authority = items[0].authority;
                    authContext = new Microsoft.ADAL.AuthenticationContext(authority);
                }
                // Attempt to authorize user silently
                authContext.acquireTokenSilentAsync(resourceUri, clientId)
                .then(callback, function () {
                    error("No auth tokens availiable, need to login");
                });
            }, function (err) {
                error("Failed to login: " + pre(err));
            });
        }

        function login(callback) {
            if (!authContext) {
                authContext = new Microsoft.ADAL.AuthenticationContext(authority);
            }

           authContext.tokenCache.readItems().then(function (items) {
                if (items.length > 0) {
                    authority = items[0].authority;
                    authContext = new Microsoft.ADAL.AuthenticationContext(authority);
                }
                // Attempt to authorize user silently
                authContext.acquireTokenSilentAsync(resourceUri, clientId)
                .then(callback, function () {
                    // We require user credentials so triggers authentication dialog
                    authContext.acquireTokenAsync(resourceUri, clientId, redirectUri)
                    .then(callback, function (err) {
                        error("Failed to authenticate: " + err);
                    });
                });
            }, function (err) {
                error("Failed to login: " + pre(err));
            });
        };

        return {
            login: login,
            loginSilently: loginSilently,
       };
    };
})();

Add android platform fails

I am using following command to add the Android platform: cordova platform add android@97718a0a25ec50fedf7b023ae63bfcffbcfafb4b. But it fails with error "Unable to fetch platform android@97718a0: Error: tunneling socket could not be established, cause=connect ECONNREFUSED".

On a side note, I am successfully able to add iOS platform.

Any help will be appreciated.

Thanks.

Refresh Token is missing on Android 5.0.1

ADAL for Cordova doesn't seem to be providing a refresh token when a authenticating with my app.

I have two applications set up in my Azure AD:
App 1: set up as Native client application. (
App 2: set up as a Web application.

I am trying to add authentication for App 1 and get a token to call App 2:

var resourceUrl = APP ID URI for App 2
var appId = client id for App 1
var redirectUrl = Reply URL for App 1

authContext.acquireTokenAsync(resourceUrl, appId, redirectUrl)
.then(function(authResult)) {
// ...
});

authResult does not contain a refresh token. How do I get one so I don't have to log in every hour?

How about a logout function?

The plugin currently provides ways to login, but how about logout? We all use applications on our smartphone, most of those provide a logout functionality, no?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.