java.util.concurrent.ExecutionException: java.lang.Exception: Server returned error in RSTR - ErrorCode: FailedAuthentication : FaultMessage: Authentication Failure

Anuj Oscar 6 Reputation points
2021-08-24T19:39:20.737+00:00

We have created an Azure app and granted all required permissions for two different email ids but with one we are able to acquire the token and with the other we are getting below error. The email IDs have no any 3rd party authentication like Okta.

Why is the same app working for an email and not working for the other one?

// Code snippet
UserNamePasswordParameters parameters = getUserNamePasswordParameters(scopes, username, password);
Future<IAuthenticationResult> aResult = app.acquireToken(parameters);
IAuthenticationResult result = (IAuthenticationResult)aResult.get();

2021-08-24 14:03:41,785 ERROR [Thread-200] [com.microsoft.aad.msal4j.PublicClientApplication] [] [dd.trace_id= dd.span_id=] [Correlation ID: REMOVED] Execution of class com.microsoft.aad.msal4j.AcquireTokenByAuthorizationGrantSupplier failed.: java.lang.Exception: Server returned error in RSTR - ErrorCode: FailedAuthentication : FaultMessage: Authentication Failure
at com.microsoft.aad.msal4j.WSTrustResponse.parse(WSTrustResponse.java:88)
at com.microsoft.aad.msal4j.WSTrustRequest.execute(WSTrustRequest.java:48)
at com.microsoft.aad.msal4j.WSTrustRequest.execute(WSTrustRequest.java:70)
at com.microsoft.aad.msal4j.AcquireTokenByAuthorizationGrantSupplier.processPasswordGrant(AcquireTokenByAuthorizationGrantSupplier.java:76)
at com.microsoft.aad.msal4j.AcquireTokenByAuthorizationGrantSupplier.execute(AcquireTokenByAuthorizationGrantSupplier.java:33)
at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:59)
at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:17)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)
at java.lang.Thread.run(Thread.java:748)

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,773 questions
0 comments No comments
{count} vote