/token

From wikieduonline
Jump to navigation Jump to search
/oauth2/token
/oauth2/v1/token
grant_type=client_credentials
code=$code # Code is obtained from /authorize
grant_type=authorization_code

Example[edit]

curl -s -X POST http://localhost:8080/token \
 -H 'Content-Type: application/x-www-form-urlencoded' \
 -d 'grant_type=client_credentials' \
 -d 'client_id=test-client' \
 -d 'client_secret=test-secret' \
 -d 'scope=openid profile email' | jq

{
 "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InhSS2R5UzNpTExXMWNBZXZKQ205ZEpQaWpaRHo0VTNyMmEwUFVRQW9FRHcifQ.eyJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAiLCJpYXQiOjE3Nzk4NjUxMDcsImV4cCI6MTc3OTg2ODcwNywibmJmIjoxNzc5ODY1MDk3LCJzY29wZSI6Im9wZW5pZCBwcm9maWxlIGVtYWlsIn0.s4dwbjI7trzVtJvE9UnzV4JLxaruco5Pe0yOsV8TmBbuMmBaoc3Kj-QqjK2Z7ge2NRk3pIlRELRuHJ4kaG7TQwl3eSn8m99b5k4j4PwV-OL8gw2ekjvV6zCaCKaFrVDTTJfTO3HQsWG94XipvbK_6_LgZUibrT8MC_DA0zoPBPc",
 "token_type": "Bearer",
 "expires_in": 3600,
 "scope": "openid profile email"
}

Decode token[edit]

set token (curl -s -X POST http://localhost:8080/token \
 -d 'grant_type=client_credentials' \
 -d 'client_id=test-client' \
 -d 'scope=openid' | jq -r .access_token)

echo $token | cut -d. -f2 | base64 -d 2>/dev/null | jq
{
 "iss": "http://localhost:8080",
 "iat": 1779865427,
 "exp": 1779869027,
 "nbf": 1779865417,
 "scope": "openid"
}

Activities[edit]

Related[edit]

See also[edit]

Advertising: