Coder Social home page Coder Social logo

luismendes070 / auth0-java-oauth-examples Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oktadev/auth0-java-oauth-examples

1.0 2.0 0.0 205 KB

OAuth in Java frameworks

Home Page: https://developer.okta.com/blog/2022/06/16/oauth-java

License: Apache License 2.0

Shell 0.21% Java 45.16% HTML 21.42% Batchfile 33.21%
micronaut okta 2023 java java-17 prerequisites micronaut-framework micronaut-java-application

auth0-java-oauth-examples's Introduction

Java OAuth Examples

See this demo script to learn how these apps were created.

Get the Code

Clone this repo to begin.

git clone https://github.com/oktadev/auth0-java-oauth-examples.git
cd auth0-java-oauth-examples

Configure Spring Boot

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

API Access with OAuth 2.0

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"

Configure Quarkus

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"

Configure Micronaut

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"

Learn More

For more details on Java and OAuth, please read OAuth for Java Developers.

auth0-java-oauth-examples's People

Contributors

mraible avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.