Auth0 Home Blog Docs

Android request scope with Lock

lock
jwt
android

#1

I followed the quickstart guide to create a spring boot appliation using spring security and auth0.
I can get an access token for my resources with Curl using

curl --request POST \
  --url 'https://caroni.eu.auth0.com/oauth/token' \
  --header 'content-type: application/json' \
  --data '{"grant_type":"password", "username":"USERNAME_OR_EMAIL", "password":"PASSWORD", "audience":"API_IDENTIFIER", "scope":"read:photos update:photos create:photos", "client_id": "ID", "client_secret": SECRET"
 }'

But when I use Lock on Android, how can I can an access token for the photos resource? With Curl I get a long jwt but credentials.getAccessToken() in the Lock callback is only about a dozen characters long.


#2

For Lock Android (v2) ensure that you use a configuration similar to the following in order to ensure that the request is performed for API authorization and includes the correct scopes:

Auth0 auth0 = new Auth0("[client_id]", "[auth0_account_domain]");

auth0.setOIDCConformant(true);

lock = Lock.newBuilder(auth0, callback)
        .withScope("openid read:photos update:photos create:photos")
        .withAudience("https://api.example.com/identifier")
        .build(this);

#3

@jmangelo you just saved me. Apparently I missed the combination of setOIDCConformant(true)and withAudience()


#4

@jmangelo you just saved me. Apparently I missed the combination of setOIDCConformant(true)and withAudience()


#5