> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Authorization Code Flow with OIDC

> Learn how the OIDC-conformant pipeline affects the Authorization Code Flow.

The [Authorization Code Flow](/docs/docs/get-started/authentication-and-authorization-flow/authorization-code-flow) is used by server-side applications that are capable of securely storing secrets, or by native applications through [Authorization Code Flow with PKCE](/docs/docs/get-started/authentication-and-authorization-flow/authorization-code-flow-with-pkce).

The OIDC-conformant pipeline affects the Authorization Code Flow in the following areas:

* Authentication request
* Authentication response
* Code exchange request
* Code exchange response
* ID token (ID Token: Credential meant for the client itself, rather than for accessing a resource.) structure
* Access token (Access Token: Authorization credential, in the form of an opaque string or JWT, used to access an API.) structure

## Authentication request

### Legacy

```http lines theme={null}
GET /authorize?
    response_type=code
    &scope=openid email favorite_color offline_access
    &client_id=123
    &state=af0ifjsldkj
    &redirect_uri=https://app.example.com/callback
    &device=my-device-name
```

The `device` parameter is only needed if requesting a refresh token (Refresh Token: Token used to obtain a renewed Access Token without forcing users to log in again.) by passing the `offline_access` scope. To learn more, read, [Refresh Tokens](/docs/docs/secure/tokens/refresh-tokens).

### OIDC-conformant

```http lines theme={null}
GET /authorize?
    response_type=code
    &scope=openid email offline_access
    &client_id=123
    &state=af0ifjsldkj
    &redirect_uri=https://app.example.com/callback
    &audience=https://api.example.com
```

* `favorite_color` is no longer a valid scope value.
* The `device` parameter is removed.
* The `audience` parameter is optional.

## Authentication response

The response from Auth0 is identical in both pipelines:

```json lines theme={null}
HTTP/1.1 302 Found
Location: https://app.example.com/callback?
    code=SplxlOBeZQQYbYS6WxSbIA
    &state=af0ifjsldkj
```

## Code exchange request - Authorization Code flow

An authorization code can be exchanged in the same way in both pipelines:

## Code exchange request - Authorization Code flow with PKCE

An authorization code can be exchanged in the same way in both pipelines:

## Code exchange response

### Legacy

```json lines theme={null}
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store
Pragma: no-cache
{
    "access_token": "SlAV32hkKG",
    "token_type": "Bearer",
    "refresh_token": "8xLOxBtZp8",
    "expires_in": 3600,
    "id_token": "eyJ..."
}
```

* The returned Access Token is only valid for calling the [`/userinfo`](/docs/docs/api/authentication#get-user-info) endpoint.
* A refresh token will be returned only if a `device` parameter was passed and the `offline_access` scope was requested.

### OIDC-conformant

```json lines theme={null}
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store
Pragma: no-cache
{
    "access_token": "eyJ...",
    "token_type": "Bearer",
    "refresh_token": "8xLOxBtZp8",
    "expires_in": 3600,
    "id_token": "eyJ..."
}
```

* The returned access token is valid for optionally calling the API specified in the `audience` parameter and the [`/userinfo`](/docs/docs/api/authentication#get-user-info) endpoint (provided that the API uses `RS256` as the [signing algorithm](/docs/docs/get-started/applications/signing-algorithms) and `openid` is used as a `scope` parameter). If you are not implementing your own Resource Server (Resource Server: Server hosting protected resources. Resource servers accept and respond to protected resource requests.) (API), then you can use `https://{$account.namespace}/userinfo` as the `audience` parameter, which will return an opaque Access Token.
* A refresh token will be returned only if the `offline_access` scope was granted.

## ID token structure

### Legacy

### OIDC-conformant

The `favorite_color` claim must be added through an Auth0 Action. To learn more, read [Create Custom Claims](/docs/docs/secure/tokens/json-web-tokens/create-custom-claims).

## Access token structure (optional)

### Legacy

```bash HTTP lines theme={null}
SlAV32hkKG
```

The returned access token is opaque and only valid for calling the [`/userinfo`](/docs/docs/api/authentication#get-user-info) endpoint.

### OIDC-conformant

The returned access token is valid for optionally calling the API specified in the `audience` parameter and the [`/userinfo`](/docs/docs/api/authentication#get-user-info) endpoint (provided that the API uses `RS256` as the signing algorithm (Signing Algorithm: Algorithm used to digitally sign tokens to ensure the token has not been tampered with.) and `openid` is used as a `scope` parameter).

If you are not implementing your own resource server (API), then you can use `https://{$account.namespace}/userinfo` as the `audience` parameter, which will return an opaque access token.

## Learn more

* [Access Tokens with OIDC](/docs/docs/authenticate/login/oidc-conformant-authentication/oidc-adoption-access-tokens)
* [External APIs with OIDC](/docs/docs/authenticate/login/oidc-conformant-authentication/oidc-adoption-apis)
* [Client Credentials Flow with OIDC](/docs/docs/authenticate/login/oidc-conformant-authentication/oidc-adoption-client-credentials-flow)
* [Implicit Flow with OIDC](/docs/docs/authenticate/login/oidc-conformant-authentication/oidc-adoption-implicit-flow)
* [Refresh Tokens with OIDC](/docs/docs/authenticate/login/oidc-conformant-authentication/oidc-adoption-refresh-tokens)
* [Resource Owner Password Flow with OIDC](/docs/docs/authenticate/login/oidc-conformant-authentication/oidc-adoption-rop-flow)
