Password Grant Type endpoint

Endpoint URL: POST /oauth2/token

Endpoint is used for exchanging user credentials for access token.

Request

Example request for token
$ curl --location --request POST 'https://connect.okonto.pl/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'client_id=www.example.com.front.onetapi.pl' \
--data-urlencode 'client_secret=g9alssde0fltp05ds7em' \
--data-urlencode 'username=testowy.roman@op.pl' \
--data-urlencode 'password=9CNxsKPQZY'

Parameters:

  • client_id - unique identifier of your service

  • client_secret - secret for your client_id

  • username - username

  • password - password

Headers:

  • Content-Type - should be set to application/x-www-form-urlencoded and parameters should be send in this format

Response

Example response for getting token request
{
    "access_token": "047b0a8339c7fb9f623d3e2e8ae69c2z3eh5r4df1501pa34cba8439f7d0c2c1fcs",
    "token_type": "bearer",
    "expires_in": 36000,
    "refresh_token": "3786016856301de8f1e7b47036op24df820e683863e2908fb7544ceb9737f1d8cs"
}

Errors handling

  • 400 BAD REQUEST - for all client side errors.

  • 503 SERVICE UNAVAILABLE - for problems encountered on the server side.