Skip to content

Service: OAuth2 Token Request with Authorization Code Grant

Eliza Margaretha edited this page Apr 17, 2023 · 4 revisions

OAuth2 token request with authorization code grant requires an authorization code. A client can obtain an authorization code by sending an authorization request to KorAP authorization server.

This service requires client authentication for confidential clients. Client credentials should be included either in Authorization header or in the request body.

Available in: full version

Method: POST

Service URL: root/oauth2/token

Parameters

Header Parameters

Name Required Description Value
Authorization yes, for confidential clients Client authentication with HTTP Basic Authentication mechanism. Alternatively without Authorization header, client credentials can be specified in the request body. Client authentication is required for confidential clients. client_id:client_secret encoded in Base64
Content-Type yes content type of the input data application/x-www-form-urlencoded

Request body

URL-encoded form parameters

Name Required Description Type Values
grant_type yes The OAuth2 grant type. String authorization_code
client_id yes The client identifier. String client_id given on client registration
client_secret yes, for confidential clients The client secret. Specify either in the Authorization header or the request body. Client authentication is required for confidential clients. String client_secret given on client registration
code yes An authorization code. String the authorization code obtained from authorization request
redirect_uri yes, if included in the authorization request The client's redirect URI where it receives the authorization code. It must be the same as the one registered on client registration. String

Examples

Example Client

Credentials Value
Client id dRJnpFH6RHTr6L7bNhrn7F
Client secret _IGaQqvUUrPTzRKJvqPYnA

Authorization header

  • Scheme : Basic

  • Value: Base64 encoding for client_id:client_secret

    ZFJKbnBGSDZSSFRyNkw3Yk5ocm43RjpfSUdhUXF2VVVyUFR6UktKdnFQWW5B

Authorization code grant with client authentication via Authorization header

curl -H 'Content-Type: application/x-www-form-urlencoded' 
     -H 'Authorization: Basic ZFJKbnBGSDZSSFRyNkw3Yk5ocm43RjpfSUdhUXF2VVVyUFR6UktKdnFQWW5B'
     -d 'grant_type=authorization_code
         &client_id=dRJnpFH6RHTr6L7bNhrn7F
         &redirect_uri=http://example.client.com/redirect
         &code=f351f1d6e135eff23aab1839e953' 
     http://localhost:8089/api/oauth2/token

Authorization code grant with client credentials in the request body

curl -H 'Content-Type: application/x-www-form-urlencoded' 
     -d 'grant_type=authorization_code
         &client_id=dRJnpFH6RHTr6L7bNhrn7F
         &client_secret=_IGaQqvUUrPTzRKJvqPYnA
         &redirect_uri=http://example.client.com/redirect
         &code=f351f1d6e135eff23aab1839e953' 
     http://localhost:8089/api/oauth2/token

Response

{
    "access_token": "4dcf8784ccfd26fac9bdb82778fe60e2",
    "refresh_token" : "hlWci75xb8atDiq3924NUSvOdtAh7Nlf9z",
    "scope": "search match_info",
    "token_type": "Bearer",
    "expires_in": 259200
}

Advanced Setting

Developer Setting

Search services

Metadata services

Authentication and Authorization services

Client services

Super client services

Plugin services

User services

User group services

Virtual corpus (VC) services

VC sharing services

Administrative services

Description services

Clone this wiki locally