Hi,
I recently updated a java web app using the Spark framework. Looking at some of the Java examples, and specifically the servlet one, much of this code appears to be using an older project using auth0-java-mvc-common and the 1.x APIs.
Since I needed to make this work with Spark controllers, I decided to use the new 2.x APIs (GitHub - auth0/auth0-java: Java client library for the Auth0 platform). I have everything working end-end and endpoints configured for login, logout and callback.
For the callback, I am getting back an ID and access token. And able to extract the JWT which contains all of the info I would expect given the authorization url scope of openid, profile and email.
However, I am not getting back any role information. I have a user configured, a role created and the user is assigned to the role.
Is there potentially an issue with the way Iām calling any of the APIs, or are there extra steps involved to get role information back? I have seen previous posts about needing to add custom Rules to support custom claims. And also some posts on the new Flows feature. Iāve attempted to do this with no luck.
// For login
String authorizeUrl = auth.authorizeUrl(config.getAuth0CallbackURL())
.withScope(āopenid profile email rolesā)
.build();
response.redirect(authorizeUrl);
Iām assuming roles scope is ignored. And on the callback:
String code = request.queryParams(ācodeā);
TokenRequest tokenRequest = auth.exchangeCode(code, config.getAuth0CallbackURL());
ā¦ after getting the Id token
DecodedJWT decodedToken = JWT.decode(idToken);
decodedToken.getClaims().forEach((k,v) ā logger.info("key: " + k + " value: " + v));
I can confirm all expected claims are there (sub, iss, sid, aud, iat, exp, gravatar picture value, etc).
Full code for this is available at GitHub - ericblue/spark-starter-auth0: Spark Starter Auth0
Any guidance on this would be appreciated! Iāve spent a good bit of time trying to get this working, and looked at various posts and documentation and the answer isnāt clear, unless Iām missing something obvious.
Thanks!