> For the complete documentation index, see [llms.txt](https://docs.corppass.gov.sg/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.corppass.gov.sg/technical-specifications/corppass-authorization-api-legacy/endpoints/token-endpoint.md).

# Token Endpoint

```
POST /mga/sps/oauth/oauth20/token
```

This endpoint allows the client to exchange an authorization code for an ID token and an access token.

* The ID token is a JWT that includes user information in the `sub` claim and is signed by Corppass. Relying Parties (RPs) can verify the JWT's signature using the public keys available at the Corppass JWKS endpoint.
* The Access Token is a signed JWS intended for the Corppass resource server (e.g. `/authorization-info`).

### Supported Grant Types

Grant types define the method by which a client obtains tokens from the authorization server. For the Open ID Connect (OIDC) authentication flow, Corppass supports the following grant types:

<table><thead><tr><th width="266">Grant Type</th><th>Description</th></tr></thead><tbody><tr><td><code>authorization_code</code> </td><td>Used to securely exchange an authorization code for an ID token and access token. Requires prior user authentication and is suitable for confidential clients. Refer to <a href="https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth">Section 3.1 of the OIDC Core Specification </a>for more details on this grant.</td></tr></tbody></table>

#### Authorization Code Grant

The `authorization_code` grant type allows the client to exchange an authorization code (provided to the client after the user is authenticated) for an ID token and an access token. This grant is restricted to **confidential clients**, which must authenticate themselves using **Client Assertion JWT.** The client must include a JSON Web Token (JWT) in the token request body. Corppass will verify the JWT's signature using the public key provided in the JSON Web Key Set (JWKS) during client onboarding.

#### Request

Request Headers

| Header       | Value                                            |
| ------------ | ------------------------------------------------ |
| Content-Type | application/x-www-form-urlencoded; charset=utf-8 |

Request Body

<table><thead><tr><th width="239.6953125">Field</th><th>Description</th></tr></thead><tbody><tr><td>redirect_uri </td><td>The redirect URI used in the current authentication session.</td></tr><tr><td>grant_type </td><td>The type of grant being requested. This must be set to <code>authorization_code</code>.</td></tr><tr><td>code </td><td>The authorization code issued during the <code>/authorize</code>  call.</td></tr><tr><td>client_assertion_type </td><td>Must be set to <code>urn:ietf:params:oauth:client-assertion-type:jwt-bearer</code> </td></tr><tr><td>client_assertion </td><td>A JWT identifying the client. Refer to <a href="/pages/LywRxjs8azw2UCtFr8yf">Client Assertion JWT</a> section for more details about the JWT structure.</td></tr><tr><td>client_id</td><td>The client identifier assigned to the Relying Party during onboarding with Corppass.</td></tr><tr><td>code_verifier</td><td>A cryptographic random string generated and is used to compare with <code>code_challenge</code> sent during the /authorize or /request call.</td></tr></tbody></table>

#### Response

Successful Response Example

<table data-header-hidden><thead><tr><th></th></tr></thead><tbody><tr><td><pre><code>{
    "access_token": "eyJraWQiOiJueGlKSk5OVnh4blRrVTJ3TDY1VEkyUGtJTElKT1VSU1RRU0FCTHVIMmtFIiwiYWxnIjoiRVMyNTYifQ.eyJleHAiOjE2MjQwODQ4MjMsImlhdCI6MTYyNDA4NDIyMywiaXNzIjoiaHR0cHM6Ly9jb3JwcGFzc3JwMDMiLCJhdWQiOiJ2T0lsaldWckd5Qk1LNmYzMVFZcSIsInNjb3BlIjpbImF1dGhpbmZvIiwidHBhdXRoaW5mbyJdfQ.jzzTSQw5w3B_88KgqzThrP237wYWkuuzBdRpHnT4iNoqWAjV8KsXDqwBgOnECsFBeshJXahMDswyqw6xlgTO9g",
    "scope": "openid",
    "id_token": "eyJraWQiOiJueGlKSk5OVnh4blRrVTJ3TDY1VEkyUGtJTElKT1VSU1RRU0FCTHVIMmtFIiwiYWxnIjoiRVMyNTYifQ.eyJlbnRpdHlJbmZvIjp7IkNQRW50SUQiOiJWQlIwMDAwMDQiLCJDUEVudF9UWVBFIjoiVUVOIiwiQ1BFbnRfU3RhdHVzIjoiUmVnaXN0ZXJlZCIsIkNQTm9uVUVOX0NvdW50cnkiOiIiLCJDUE5vblVFTl9SZWdObyI6IiIsIkNQTm9uVUVOX05hbWUiOiIifSwiYW1yIjpbInB3ZCJdLCJpYXQiOjE2MjQwODQyMjIsImlzcyI6Imh0dHBzOi8vY29ycHBhc3NycDAzIiwic3ViIjoicz1udWxsLHU9YW1pdGVzaCxjPW51bGwiLCJhdF9oYXNoIjoiMncxWjlBNW9qZExic2hSLUIwbFV4QSIsImV4cCI6MTYyNDA4NzgyMiwiYXVkIjoidk9JbGpXVnJHeUJNSzZmMzFRWXEifQ.lwTieBCXxOHMtKFkpLZDarzGe5QsZiFnZoWxVoSPLEzPhTABMgStGknzlf9m1hZiw6rCP_4InngFNLeh8DeztA",
    "token_type": "Bearer",
    "expires_in": 599
}
</code></pre></td></tr></tbody></table>

Response Body Fields

<table><thead><tr><th width="153">Field</th><th width="130">Required</th><th width="107">Type</th><th>Description</th></tr></thead><tbody><tr><td>access_token </td><td>Yes</td><td>JWS</td><td>The access token containing standard claims in JWS format, signed by Corppass. Refer to the <a href="/pages/fCjeYWVJ7oMMDzd87q4U">Access Token</a> section for more details.</td></tr><tr><td>scope </td><td>Yes</td><td>String</td><td>The scopes granted for the issued tokens. This field may include <code>openid</code> along with other scopes requested during authorization.</td></tr><tr><td>id_token </td><td>Yes</td><td>JWE</td><td>The ID token containing relevant claims in JWT format, signed by Corppass. Refer to the <a href="/pages/sLKLyJetAEsFmM2GFeEC">ID Token</a> section for more details.</td></tr><tr><td>token_type </td><td>Yes</td><td>String</td><td>The type of token issued. Currently, only <code>Bearer</code> is supported.</td></tr><tr><td>expires_in</td><td>Yes</td><td>Numeric</td><td>The remaining lifetime of the access token in seconds.</td></tr></tbody></table>
