---
title: OAuth2FailureContext
description: When an OAuth 2.0 authorization operation fails, the error and error description provided by the authorization service are injected into this context for use downstream.
component: pinggateway
version: 2026
page_id: pinggateway:reference:OAuth2FailureContext
canonical_url: https://docs.pingidentity.com/pinggateway/2026/reference/OAuth2FailureContext.html
revdate: 2025-06-02T18:01:47Z
section_ids:
  OAuth2FailureContext-properties: Properties
  OAuth2FailureContext-examples: Examples
  OAuth2FailureContext-moreinfo: More information
---

# OAuth2FailureContext

When an OAuth 2.0 authorization operation fails, the error and error description provided by the authorization service are injected into this context for use downstream.

The amount and type of information in the context depends on when a failure occurs.

This context is created by [AuthorizationCodeOAuth2ClientFilter](AuthorizationCodeOAuth2ClientFilter.html) and [OAuth2TokenExchangeFilter](OAuth2TokenExchangeFilter.html).

This context supports OAuth 2.0 error messages in the format given by [RFC 6749](https://datatracker.ietf.org/doc/html/rfc6749#section-5.2).

## Properties

The context is named `OAuth2Failure`, and is accessible at `${contexts.oauth2Failure}`. The context has the following properties:

* `"error"`: *[java.lang.String](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html)*

  The error field name.

* `"description"`: *[java.lang.String](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html)*

  Error description field name.

* `"exception"`: *[org.forgerock.openig.filter.oauth2.client.OAuth2ErrorException](../_attachments/apidocs/org/forgerock/openig/filter/oauth2/client/OAuth2ErrorException.html)*

  The OAuth 2.0 exception associated with the token exchange error.

## Examples

For examples that use `${contexts.oauth2Failure.error}` and `${contexts.oauth2Failure.description`, refer to the routes in [OAuth 2.0 token exchange with PingAM](../gateway-guide/token-exchange.html) and [Discovery and dynamic registration with PingAM](../gateway-guide/oidc-dynamic.html).

## More information

[org.forgerock.openig.filter.oauth2.OAuth2FailureContext](../_attachments/apidocs/org/forgerock/openig/filter/oauth2/OAuth2FailureContext.html)

[OAuth2TokenExchangeContext](OAuth2TokenExchangeContext.html)

[OAuth2TokenExchangeFilter](OAuth2TokenExchangeFilter.html)

[RFC 6749: Error Response](https://www.rfc-editor.org/rfc/rfc6749#section-5.2)
