API Documentation
A list of API endpoints supported by sgID.
Last updated
A list of API endpoints supported by sgID.
Last updated
The API endpoints listed here are for reference purposes only. sgID users are strongly recommended to use the SDK(s) provided which sends these requests for you.
If there are no SDKs provided for your programming language, please refer to Custom Integration on how to set up your own integration.
Do not reuse the example code challenge and code verifier provided in the API examples, as this would expose your API requests to PKCE guessing attacks by malicious users. Refer to the example code under the SDKs section on how to generate valid <code_verifier, code_challenge>
pairs.
Create an sgID authorization URL to redirect your user to so that they can authenticate with Singpass
/v2/oauth/authorize
Must be set to code
because sgID only supports the authorization code flow
code
code
sgID client ID which was provided to you during client registration
MYCLIENT-PROD
The callback URL that was provided during registration. sgID redirects to this URL with the authorization code after the user authenticates with Singpass
https://example.com/callback
A URL-encoded string of the scopes your client will request for
openid%20myinfo.name%20myinfo.passport_expiry_date%20myinfo.nric_number
Randomly generated string to be returned in the ID token. Used to prevent replay attacks as part of the OpenID Connect 1.0 spec
BQO8SV3ALIYA808IZ8O7PKWRI8A8X6MI
A unique and non-guessable value associated with each authentication request about to be initiated. Used to prevent CSRF attacks and to maintain state as part of the OAuth 2.0 spec (RECOMMENDED)
tk39drykro3
The method used to verify the code challenge. Throws an error response if the value is not 'S256'
S256
A SHA256 hashed string that should be used to verify against the code verifier in the token request
CUZX5qE8Wvye6kS_SasIsa8MMxacJftmWdsIA_iKp3I
Exchange auth code for access token as part of sgID authorization code flow
/v2/oauth/token
sgID client ID which was provided to you during client registration
sgID client secret which was provided to you during client registration
Authorization code that was received from the callback URL after the user authenticates with Singpass
This field must take the value authorization_code
as sgID only supports the OAuth 2.0 authorization code flow
A cryptographically random string that was used to generate your code challenge in the authorization request