# Summary of OAuth2 Authorization Flow

By following the OAuth2 authorization flow, your application can securely obtain access tokens from AIRisk API. This design ensures that users can grant, or revoke access as needed and that your app never needs to handle raw passwords. It also allows AIRisk to scope the issued tokens to specific users or to your application overall, depending on the presence of the `userid` parameter.

* Furthermore, it allows AIRisk admins to define sets of credentials and allowed redirect uris (corresponding to `APIUser` instances), and then share the client id, secret, and the redirect uris as well as set them accordingly. These are all one needs to be able to get a generic token via the authentication process.
* Moreover, the admins also have control over the `ApplicationUser` instances (each with a unique `userid`, corresponding with an actual user of the platform), the agents they can access, particular chat-related settings, as well as their `Company` to which they belong to further scope their permissions.

For more information on [OAuth2](https://oauth.net/2/) and best practices, you may refer to external resources like the [official OAuth 2.0 framework specification RFC 6749](https://datatracker.ietf.org/doc/html/rfc6749) for in-depth details, or approachable guides such as [OAuth 2 Simplified](https://aaronparecki.com/oauth-2-simplified/) and [the DigitalOcean tutorial "An Introduction to OAuth 2"](https://www.digitalocean.com/community/tutorials/an-introduction-to-oauth-2) for a conceptual overview. Furthermore, refer to [this official oauth2 documentation on the `state` parameter convention](https://auth0.com/docs/secure/attack-protection/state-parameters) to better understand its purpose and usage. Using this information to properly authenticate and acquire tokens, you may now explore the AIRisk API endpoints with authenticated requests, knowing that the OAuth2 standard is handling the authorization securely under the hood. Happy building!


---

# Agent Instructions: 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:

```
GET https://docs.aicrisk.com/api-overview/airisk-api-oauth2-authentication/summary-of-oauth2-authorization-flow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
