Reputation: 1336
I try to use Auth0 for android I think i have everything done bud still i get this error:
E/LockActivity: Failed to authenticate the user: An error occurred when trying to authenticate with the server.
com.auth0.android.authentication.AuthenticationException: An error occurred when trying to authenticate with the server.
...
my class for run auth:
package com.my.awesome.app.modules;
public class AuthZeroModule extends ReactContextBaseJavaModule {
private ReactApplicationContext mReactContext;
private Lock mLock;
public AuthZeroModule(ReactApplicationContext reactContext) {
super(reactContext);
mReactContext = reactContext;
}
@Override
public String getName() {
return "AuthZero";
}
@ReactMethod
public void authenticate() {
Log.e("LSA", "=============authenticate");
Log.e("LSA", "=============CLIENT: " + AUTH0_CLIENT + " DOMAIN: " + AUTH0_DOMAIN);
Auth0 account = new Auth0("ZXXXXXXXXXXXXXXXXI", "myawesomeauth.eu.auth0.com");
account.setOIDCConformant(true);
mLock = Lock.newBuilder(account, callback)
.withScheme("https")
.withAudience("myapp.middleware.api")
// .withAudience("https://myawesomeauth.eu.auth0.com/authorize")
.allowLogIn(true)
.aut
.build(mReactContext);
mReactContext.startActivity(mLock.newIntent(mReactContext));
}
private LockCallback callback = new AuthenticationCallback() {
@Override
public void onAuthentication(Credentials credentials) {
Log.e("LSA", "OK -->" + credentials.getAccessToken());
}
@Override
public void onCanceled() {
Log.e("LSA", "OK --> User pressed back.");
}
@Override
public void onError(LockException error) {
Log.e("LSA", "OK -->" + error.getMessage());
}
};
}
and inside Auth0 admin i have prepare callback in field 'Allowed Callback URLs':
https://myawesomeauth.eu.auth0.com/androidcom.my.awesome.app/callback,
And i have turn on Use Auth0 instead of the IdP to do Single Sign On
I use same client for IOS and every things work fine bud android have this authentication error.
I will be grateful for every advice ... thanks
Upvotes: 7
Views: 1841
Reputation: 26
Check your logs: Auth0 Dashboard > Monitoring > logs
I had a similar issue, tried everything, but this is just a general error thrown, the real error is in the logs of auth0.
Upvotes: 0
Reputation: 2548
Go to the Auth0 Dashboard > Applications > Your App > Show Advanced Settings > Grant Types.
check if the Password grant checked or not
Upvotes: 2
Reputation: 121
Have just encountered a similar issue. The error is not very detailed frustratingly.
Add
account.setLoggingEnabled(true)
below the following for a more detailed error.
Auth0 account = new Auth0("ZXXXXXXXXXXXXXXXXI", "myawesomeauth.eu.auth0.com");
account.setOIDCConformant(true);
Only use this in preproduction as it logs secrets when everything is working correctly.
Upvotes: 0