ADAL For Java on Mobile Devices: Prompt is Not Allowed


I've a Java program using ADAL4J that works great on a non-mobile device but when deployed to any mobile devices via Oracle MAF (which deploys as Cordova, HTML5, CSS), it fails on the AuthenticationContext method.

The error is:

com.microsoft.aad.adal.AuthenticationException: Prompt is not allowed and failed to get token:

Here is the main code:

service = Executors.newFixedThreadPool(1); String url = AUTHORIZATION_ENDPOINT + tenantId + "/oauth2/authorize"; //Next line is where it fails authContext = new AuthenticationContext(url, false, service); Future<AuthenticationResult> future = authContext.acquireToken(ARM_ENDPOINT, clientId, username, credential, null); result = future.get(); System.out.println("Access Token - " + result.getAccessToken()); System.out.println("ID Token - " + result.getIdToken());

Based on the research I've done it appears I may need to use the AcquireTokenSilent method instead, however this method does not exist in the ADAL for Java library (using ADAL4J 1.1.3, most recent as of this post). I did see that there is an <a href="https://github.com/AzureAD/azure-activedirectory-library-for-cordova" rel="nofollow" title="ADAL For Cordova">ADAL for Cordova</a> library that contains this method that may work. However that uses NodeJS and I'd prefer to stick with a Java solution if possible.

Would appreciate any assistance. Thanks.

EDIT: I think the main issue if that the ADAL4J library does not support the AuthenticationContext.tokenCache property nor does it include support for the <a href="https://msdn.microsoft.com/en-us/library/microsoft.identitymodel.clients.activedirectory.promptbehavior.aspx" rel="nofollow">PromptBehavior</a> option that is there in the device specific ADAL implementations.

If true, guess I'll either have to try the ADAL for Cordova or each device ADAL SDK.


According to your description, based on my understanding, I think you want to create a mobile application cross platform like iOS/Android/etc using Oracle MAF in Java.

So per my experience, the solution which be suitable for your needs in Java is using OAuth2 REST APIs for authentication via Java HTTP client on Azure AD, please refer to the offical tutorial <a href="https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols-oauth-code" rel="nofollow">OAuth 2.0 Authorization Code Flow</a>.

If just for Android, you can directly use <a href="https://github.com/AzureAD/azure-activedirectory-library-for-android" rel="nofollow">ADAL for Android</a> to do that. Otherwise, it seems that there is not any existing library to directly support for authentication within multi-platform in Java. Hope it helps.


  • How To Add Calendar Events to Outlook 365 Using C# MSGraph
  • AngularJS component with externally hosted templateUrl?
  • How to fetch the file list from gcs?
  • Error when trying to send an email using Gmail API in Java
  • help('modules') crashing? Not sure how to fix
  • Can I use AllJoyn Framework for Wifi Direct in iOS?
  • How can I sort a a table with VBA with given text condition?
  • Passing 1 of 3 values to a Sub
  • How to test if a URL from an Eclipse bundle is a directory?
  • ActiveRecord query for a count of new users by day
  • Set the selected item in dropdownlist in MVC3
  • How to create a file in java without a extension
  • Spring Data JPA custom method causing PropertyReferenceException
  • Using $this when not in object context
  • Splitting given String into two variables - php
  • Different response to non-authenticated users and AJAX calls
  • What is Eclipse's Declaration View used for?
  • How do I fake an specific browser client when using Java's Net library?
  • Counter field in MS Access, how to generate?
  • How reduce the height of an mschart by breaking up the y-axis
  • Possible to stop flickering java tooltip in heavyweight mode?
  • Perl system calls when running as another user using sudo
  • sending/ receiving email in Java
  • How to set my toolbar fixed while scrolling android
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • AT Commands to Send SMS not working in Windows 8.1
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • How to get Windows thread pool to call class member function?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • apache spark aggregate function using min value
  • Bitwise OR returns boolean when one of operands is nil
  • sending mail using smtp is too slow
  • Sorting a 2D array using the second column C++
  • costura.fody for a dll that references another dll
  • Binding checkboxes to object values in AngularJs
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal