> For the complete documentation index, see [llms.txt](https://talque.gitbook.io/public/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://talque.gitbook.io/public/sso/oauth2-flow/request-an-authorization-code.md).

# Request an Authorization Code

To request an authorization code, you must direct the user's browser to the talque OAuth 2.0 authorization endpoint. Once the request is made, one of the following two situations will occur:

* If the user has not previously accepted the application's permission request, or the grant has expired or been manually revoked by the user, the browser will be redirected to the talque authorization screen. When the user completes the authorization process, the browser is redirected to the URL provided in the redirect\_uri query parameter.&#x20;
* If there is a valid existing permission grant from the user, the authorization screen is by-passed and the user is immediately redirected to the URL provided in the redirect\_uri query parameter.&#x20;

Note that if you ever change the scope permissions that your application requires, your users will have to re-authenticate to ensure that they have explicitly granted your application all of the permissions that it requests on their behalf.

## Request Authorization Code

<mark style="color:blue;">`GET`</mark> `https://www.talque.com/oauth2/authorization`

Redirect the browser to this URL to request an authorization code

#### Query Parameters

| Name           | Type   | Description                                                                     |
| -------------- | ------ | ------------------------------------------------------------------------------- |
| scope          | string | Space-separated list of scope values (note that the space must be URL encoded)  |
| response\_type | string | Should always be "code"                                                         |
| client\_id     | string | Your API client ID                                                              |
| redirect\_url  | string | One of the redirect urls configured for your application.                       |
| state          | string | A unique string of your choice that cannot be guessed. To protect against CSRF. |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}

{% tab title="308 " %}

```
```

{% endtab %}
{% endtabs %}

If the user approves the OAuth2 request, the browser is redirect to the callback URL defined in your redirect\_uri parameter. Added to the redirect\_uri will be two important URL query parameters:&#x20;

* `code`: the OAuth 2.0 authorization code.
* `state`: A value used to protect against possible CSRF attacks.&#x20;

First of all, you must compare the returned state with the state that you passed in. Any difference indicates a CSRF attack and you should throw an HTTP 401 error code.

The code is a value that you will exchange with talque for the actual OAuth 2.0 access token in the next step of the authentication process. For security reasons, the authorization code has a very short lifespan and must be used within moments of receiving it.

The authorization code (as well as the access code in the next step) are relatively long strings. Your code should allow for at least 1000 characters.

### Available scopes

The following elementary scopes are available in talque:

* `EMAIL`:  This scope allows read access to the user's primary email address&#x20;
* `PROFILE`: This scope allows read access to the user's public profile information. This includes&#x20;

  * First and last name
  * Company name
  * Job title
  * Profile photo
  * Account registration date


---

# 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://talque.gitbook.io/public/sso/oauth2-flow/request-an-authorization-code.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.
