---
title: "OpenID Connect Hybrid Flow"
description: "Learn about the OpenID Connect hybrid flow, its components, and how it combines the implicit and authorization code flows for secure authentication."
url: "https://curity.io/resources/learn/oauth-hybrid-flow/"
date: "2025-05-20"
area: "develop"
topic: "openid-connect"
keywords: "openid connect, hybrid flow, openid connect hybrid flow, openid connect hybrid flow explained, openid connect hybrid flow authorization, openid connect hybrid flow token, openid connect hybrid flow authorization endpoint"
---

# OpenID Connect Hybrid Flow

The hybrid flow is an OpenID Connect flow that incorporates characteristics of both the implicit flow and the authorization code flow. It enables clients to obtain ID tokens straight from the authorization endpoint (via front-channel), while still being able to obtain access and refresh tokens from the token endpoint (via back-channel). This makes the hybrid flow particularly suitable for applications needing a balance between security and responsiveness.

This article explains the main components of the hybrid flow and how it combines the [implicit flow](https://curity.io/resources/learn/oauth-implicit-flow/) for the ID token with the [authorization code flow](https://curity.io/resources/learn/oauth-code-flow/) for the access token. If you want to try it yourself, follow the step-by-step guide to run the [hybrid flow](https://curity.io/resources/learn/hybrid-flow/).

Best Practices

The OAuth implicit flow is deprecated. As a result, do not include the string `token` in the `response_type` request parameter. Only use `code id_token` for the hybrid flow. If possible, rely on the [code flow](https://curity.io/resources/learn/oauth-code-flow/) to retrieve all tokens

## How the OIDC Hybrid Flow Works

### Authorization Request and Response

![An example of the Hybrid Flow, incorporating characteristics of both the Implicit flow and the Authorization Code flow, part 1](https://curity.io/images/resources/standards/oauth/flows/hybrid-flow-1.svg) 

1.  The browser redirects to the authorization endpoint at the token service of the authorization server.
    
2.  If the user is not yet authenticated, the token service redirects to the authentication service.
    
3.  The user authenticates and is redirected back to the token service.
    
4.  The authorization server redirects back to the client with appropriate parameters in the response, based on the value of the `response_type` request parameter:
    
    -   If the client used `code id_token`, then the server returns the authorization code and an ID token.

### Token Request and Response

![An example of the Hybrid Flow, incorporating characteristics of both the Implicit flow and the Authorization Code flow, part 2](https://curity.io/images/resources/standards/oauth/flows/hybrid-flow-2.svg) 

5.  The client sends the authorization code to the token endpoint, like in the authorization code flow.
6.  The authorization server returns tokens, typically including the access token and the ID token. If the server settings permit, the authorization server also issues a refresh token.

### User Authentication

The user is authenticated during the authorization flow. Neither the OAuth nor the OpenID Connect specifications define the particulars for user authentication. It may thus involve any authentication method or multiple factors. Modern authorization servers apply conditional authentication, which adapts the flow depending on the context. In the Curity Identity Server, all user authentication is configured in the [Authentication Service](https://curity.io/authentication-service/) ensuring fine-grained control over authentication policies.

### Client Authentication

In the hybrid flow, the client is not authenticated when calling the authorization endpoint but is identified through the redirect URI. The client must authenticate at the token endpoint, though, just like in the authorization code flow. Thanks to that, the client can obtain access tokens and longer-lived refresh tokens using the back-channel during the hybrid flow.

### The Access Token

The authorization server should not return any access tokens through the front-channel (i.e., as part of the browser redirect). Instead, the client should fetch access tokens in a back-channel request from the token endpoint. The authorization server may return a refresh token as well.

The Curity Identity Server supports returning access tokens in the front-channel. However, such tokens are limited in terms of scope, lifetime, and audience to mitigate security risks. For the same reason, the Curity Identity Server does not return refresh tokens in the front-channel.

### The Refresh Token

The authorization server can, depending on its policies, return refresh tokens to the client. This token can be used to obtain more access tokens once the first one expires. The refresh token may have a very long lifetime, ranging from hours to years.

The refresh token can only be obtained from the token endpoint; the Curity Identity Server will never return it from the authorization endpoint.

## The Authorization Request

-   Method: `GET`
-   Agent: Browser
-   Response Type: Redirect to pre-registered callback URI at client with parameters in the fragment

The following table outlines the parameters for the front-channel communication in the hybrid flow.

### Request Parameters

| Parameter | Value | Mandatory | Description |
| --- | --- | --- | --- |
| client\_id | The client ID | yes | The ID of the requesting client. |
| response\_type | `code id_token`\* | yes | Defines the flow type: hybrid flow. |
| state | A random value | no | Will be provided back to the client in (4). Useful to keep track of the session in the client or to prevent unsolicited flows. |
| scope | Space-separated string of scopes | yes\* | List the scopes the client is requesting access to. \*Mandatory if ID token is requested in the `response_type`. |
| redirect\_uri | The client callback URL | yes | The URI that the client wants the authorization response in step (4) to redirect to. |
| nonce | A random value | yes\* | A value that is used to mitigate replay attacks. \*Mandatory if ID token is requested in the `response_type`. |
| code\_challenge | A high entropy random challenge | yes\* | A challenge generated by the client, if sent, the code\_verifier must be sent on the token call. \*Part of PKCE (RFC 7636), recommended. |
| code\_challenge\_method | `S256` | yes\* | The hash method to validate the PKCE (RFC 7636) flow. \*Required if `code_challenge` is included in the request. The specification recommends using `S256`. |

### Response

The authorization server creates a redirect back to the `redirect_uri`. It provides the response parameters on the fragment part of the URL. This means that only the browser can access the values of the response. The client server will not receive these values.

| Parameter | Value | Mandatory | Description |
| --- | --- | --- | --- |
| state | The same value as given in the request | yes\* | The same value as the client sent in the request. Use to match request to the redirect response. \*Mandatory if the state was sent in the request. |
| code | An Authorization Code | yes | An authorization code, to be used in the token request. |
| id\_token | JSON Web Token | yes\* | A JWT representing the ID token. \*Mandatory if the ID token is requested in the `response_type`. |

## The Token Request

### Request Parameters

-   Method: `POST`
-   Content-Type: `application/x-www-form-urlencoded`
-   Response Type: `json`

This represents the back-channel token exchange, providing enhanced confidentiality for sensitive tokens.

| Parameter | Value | Mandatory | Description |
| --- | --- | --- | --- |
| client\_id | The client ID | yes | The ID of the requesting client. |
| client\_secret | The client secret | yes\* | The secret of the client. \*Mandatory if client authentication is of type secret and the authentication is not done using basic authentication. Other methods of client authentication may require different parameters sent in the request. |
| grant\_type | `authorization_code` | yes | Tells the token endpoint to do the second part of the hybrid flow. |
| code | The authorization code | yes | The code is given in the response to the authorization request. |
| redirect\_uri | The callback URL of the Client | yes | The same redirect URI as was sent in the authorize request. |
| code\_verifier | The verifier that matches the code\_challenge | no\* | \*Mandatory if code\_challenge was used in the authorize request. |

### Response

-   Response Type: `application/json`

| Parameter | Value | Mandatory | Description |
| --- | --- | --- | --- |
| access\_token | A newly issued access token | yes | The resulting access token. |
| refresh\_token | A newly issued refresh token | no | Only issued if the client is configured to receive refresh tokens. |
| expires\_in | Expiration in seconds | yes | The time to live of the access token in seconds. |
| scope | Space-separated string | no | If not present, the requested scopes were issued. If present, the issued scopes may differ from the requested scopes. |
| token\_type | `Bearer` or other token type | yes | Describes how the token can be used. Most commonly bearer token usage. |
| id\_token | JSON Web Token | no | JWT represents the ID token. Present if `openid` scope was requested and the user has given consent to this scope. |

### Key Takeaways

The OpenID Connect hybrid flow provides a flexible and secure mechanism for handling authentication and authorization in modern web and mobile applications. By combining features of the implicit and authorization code flows, it allows clients to receive tokens both immediately and through secure exchanges, ensuring an optimal balance of user experience and security. It is particularly valuable when applications require both immediate access and long-term session management through refresh tokens.
