---
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: 7.2
page_id: pinggateway:reference:OAuth2FailureContext
canonical_url: https://docs.pingidentity.com/pinggateway/2026/reference/OAuth2FailureContext.html
llms_txt: https://docs.pingidentity.com/pinggateway/llms.txt
docs_for_agents: https://developer.pingidentity.com/build-with-ai/docs-for-agents.md
revdate: 2025-06-02T16:30:54Z
superseded_by: https://docs.pingidentity.com/pinggateway/2026/reference/OAuth2FailureContext.html
section_ids:
  OAuth2FailureContext-properties: Properties
  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.

For example, when the [OAuth2TokenExchangeFilter](Filters.html#OAuth2TokenExchangeFilter) fails to exchange a token, it injects the error and description into this context. The context is passed into calls to the `failureHandler` in the OAuth2TokenExchangeFilter.

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"`: *[string](preface.html#definition-string)*

  The error field name.

* `"description"`: *[string](preface.html#definition-string)*

  Error description field name.

* `"exception"`: *Exception*

  The OAuth 2.0 exception associated with the token exchange error.

## More information

[OAuth2TokenExchangeContext](RequestsResponsesContexts.html#OAuth2TokenExchangeContext)

[OAuth2TokenExchangeFilter](Filters.html#OAuth2TokenExchangeFilter)

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