---
title: PolicyContext object reference
description: Access the PolicyContext object in Groovy policyCtx.
component: pingaccess
version: 9.0
page_id: pingaccess:reference_guides:pa_policycontext_object_ref
canonical_url: https://docs.pingidentity.com/pingaccess/9.0/reference_guides/pa_policycontext_object_ref.html
revdate: February 6, 2023
section_ids:
  purpose: Purpose
  groovy-sample: Groovy sample
  method-summary: Method summary
---

# PolicyContext object reference

Access the PolicyContext object in Groovy `policyCtx`.

## Purpose

The PolicyContext object is a map of objects needed to perform policy decisions. The contents of the map vary based on the context of the current user flow. A common example is OAuth *(tooltip: \<div class="paragraph">
\<p>A standard framework that enables an application (OAuth client) to obtain access tokens from an OAuth authorization server for the purpose of retrieving protected resources on a resource server.\</p>
\</div>)* token information stored in an OAuthToken object contained within the context map. In this example, an OAuthToken object is retrieved from the policy context by using the `oauth_token` key. The OAuthToken object is available only for the OAuth Groovy scripts rules.

## Groovy sample

```
def oauthToken = policyCtx?.context.get("oauth_token")
```

## Method summary

| Method                                  | Description                                                     |
| --------------------------------------- | --------------------------------------------------------------- |
| objectMap\<String, Object> getContext() | Container for the [OAuthToken](pa_oauth_token_object_ref.html). |
| Exchange getExchange()                  | Returns the exchange a message relates to.                      |
