> For the complete documentation index, see [llms.txt](https://docs.developer.singpass.gov.sg/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.developer.singpass.gov.sg/docs/legacy-myinfo-v3-v4/technical-specifications/myinfo-v4/technical-concepts/oauth-2.1-concepts.md).

# OAuth 2.1 Concepts

MyInfo APIs use [OAuth2.1](https://oauth.net/2.1/) - Authorization code flow to perform authentication & authorization; it allows mobile and web clients to obtain tokens securely.

The code flow comprises 2 main parts:

1. Authorization flow that runs in the browser
2. Token flow that is a server-to-server call

***

## 1. Authorization Flow

<figure><img src="/files/r0BjIsDYJ6gLODep8Bgo" alt=""><figcaption></figcaption></figure>

1. Browser redirects to the /authorize endpoint of the AuthZ server.
2. The AuthZ server redirects to the Singpass, the AuthN server.
3. The User authenticates and redirects back to the AuthZ server.
4. The AuthZ server redirects to the consent page for user consent.&#x20;
5. The User consents.
6. The AuthZ server redirects back to the client application callback URL with a one-time token called Authorization Code(authcode)

## 2. Token Flow

<figure><img src="/files/3qaYIUh0Q5cfKa0z9Boq" alt=""><figcaption></figcaption></figure>

1. The client application makes a post request to the /token API endpoint with the Authorization code (authcode) and client\_assertion.
2. The AuthZ Server validates the authcode and client\_assertion before issuing the access\_token.

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.developer.singpass.gov.sg/docs/legacy-myinfo-v3-v4/technical-specifications/myinfo-v4/technical-concepts/oauth-2.1-concepts.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
