Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auth0 native Android error when trying to authenticate with the server

Tags:

android

auth0

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

like image 804
Lukáš Šálek Avatar asked Nov 18 '22 12:11

Lukáš Šálek


1 Answers

Go to the Auth0 Dashboard > Applications > Your App > Show Advanced Settings > Grant Types.

check if the Password grant checked or not

like image 145
MarGin Avatar answered Dec 29 '22 08:12

MarGin