spring-oauth2-jwt-authoriza.../README.md

2.0 KiB

Getting Started

Obtaining an user access token

browse with navigator

http://localhost:8081/oauth2/authorize?response_type=code&client_id=client&redirect_uri=http://localhost:8081/login/oauth2/code/oidc-client&scope=openid%20profile%20read

$ read -s CODE
$ ACCESS_TOKEN=$(curl -v "http://localhost:8081/oauth2/token" --data-urlencode "grant_type=authorization_code" --data-urlencode "code=$CODE" --data-urlencode "redirect_uri=http://localhost:8081/login/oauth2/code/oidc-client" -H 'Content-Type: application/x-www-form-urlencoded' -u "client:secret" | jq -r .access_token | tee /dev/tty)

Obtaining a client credential (machine to machine jwt token)

$ curl -v "http://localhost:8081/oauth2/token" --data-urlencode "grant_type=client_credentials" --data-urlencode "code=$CODE" --data-urlencode "redirect_uri=http://localhost:8081/login/oauth2/code/oidc-client" -H 'Content-Type: application/x-www-form-urlencoded' -u "client:secret" | jq

Using access token

$ curl -v http://localhost:8081/ping -H "Authorization: Bearer $ACCESS_TOKEN"

oidc endpoint

http://localhost:8081/.well-known/openid-configuration http://localhost:8081/.well-known/oauth-authorization-server

Reference Documentation

For further reference, please consider the following sections:

Guides

The following guides illustrate how to use some features concretely: