Auth0 Home Blog Docs

Android Access Token Not Working

lock-android

#1

We have two login mechanisms. One is Lock for web, which works fine. The other is Lock for android. With this latter login system, the access token we are provided with does not seem to validate, in that our API throws a 401 error.

The code that DOES work in web:

this.lock = new Auth0Lock(
    'xxxxx',
    'shoutapp.eu.auth0.com',
    this.lockOptions
);
this.lock.on("authenticated", $.proxy(this.onLockAuthenticated, this));
...
   localStorage.setItem('accessToken', authResult.accessToken);

The code that DOES NOT work in Android:

        Auth0 auth0 = new Auth0(getString(R.string.com_auth0_client_id), getString(R.string.com_auth0_domain));
        auth0.setOIDCConformant(true);
        lock = Lock.newBuilder(auth0, callback)
                .withAudience("https://api.shoutapp.io/")
                .build(this);
        startActivity(lock.newIntent(this));

#7

Does anyone have any ideas?


#8

FYI incase anyone has this issue in future, I had to remove the audience paramater. Iā€™m not sure why that fixed it, but it did!

as in:

lock = Lock.newBuilder(auth0, callback)
//.withAudience(ā€œhttps://api.xxxx/ā€)
.build(this);


#9

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.