See this demo script to learn how these apps were created.
Clone this repo to begin.
git clone https://github.com/oktadev/auth0-java-oauth-examples.git
cd auth0-java-oauth-examples
Create an OIDC application using the Auth0 CLI.
auth0 apps create --reveal-secrets
-
Name:
Spring Boot
-
Type: Regular Web Application
-
Allowed Callback URLs:
http://localhost:8080/login/oauth2/code/auth0
-
Allowed Logout URLs:
http://localhost:8080
Update application.properties
to use these values.
spring.security.oauth2.client.provider.auth0.issuer-uri=https://<your-auth0-domain>/
spring.security.oauth2.client.registration.auth0.client-id=<client-id>
spring.security.oauth2.client.registration.auth0.client-secret=<client-secret>
spring.security.oauth2.client.registration.auth0.scope=openid,profile,email
auth0.audience=https://<your-auth0-domain>/api/v2/
Start the app:
mvn spring-boot:run
Log in at http://localhost:8080
.
Create an access token using Auth0’s CLI:
auth0 test token -a https://<your-auth0-domain>/api/v2/
Set the access token as an environment variable:
TOKEN=eyJhbGciOiJSUzI1NiIsInR5cCI6...
Access your resource server using HTTPie:
http :8080/hello "Authorization: Bearer $TOKEN"
Update quarkus/.env
to use your Auth0 domain.
ISSUER=https://<your-auth0-domain>
Run the app:
mvn quarkus:dev
Verify you can access it with an access token.
http :8080/hello "Authorization: Bearer $TOKEN"
Update micronaut/src/main/resources/application.yml
to use your Auth0 domain.
micronaut.security.token.jwt.signatures.jwks.auth0.url: https://<your-auth0-domain>/.well-known/jwks.json
Run the app:
mvn mn:run
Verify you can access it with an access token.
http :8080/hello "Authorization: Bearer $TOKEN"
For more details on Java and OAuth, please read OAuth for Java Developers.