# Authorization Endpoint

**Endpoint:** `GET /api/oauth2`

**Purpose:** Initiate an OAuth2 authorization code request (user login & consent).

**Query Parameters**:

* `client_id` (string, <mark style="color:red;">Required</mark>)
  * &#x20;Your application’s client identifier. This value is provided when you register your app with AIRisk. It tells the authorization server which application is making the request.
* `redirect_uri` (string, <mark style="color:red;">Required</mark>)
  * &#x20;The URL in your application where users will be sent after authorization. This must match one of the allowed redirect URIs you configured for your client. After the user approves or denies the request, AIRisk will redirect their browser to this URL with additional parameters (code or error).
* `state` (string, <mark style="color:orange;">Optional</mark>)
  * A string locally generated and stored to use to prevent CSRF attacks. The value of this parameter must be stored and compared with the `state` parameter value existing alongside `code` in the response once having been redirected to the passed `redirect_uri`. The stored value must match the value retrieved from the response parameters. See [this official oauth2 documentation](https://auth0.com/docs/secure/attack-protection/state-parameters) for more information on this convention.
* `userid` (string, <mark style="color:orange;">Optional</mark>)
  * &#x20;An identifier for the user on whose behalf the authorization is being requested. Include this if you want a user-specific token. When provided, the authorization process will associate the resulting code with the specified user. If omitted, the authorization is not tied to a specific user and will result in a generic token (suitable for application-level access).
