# How to create OAuth 2.0 access token to call Pega API

**URL:** <https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477>\
**Category:** Knowledge Share\
**Tags:** sales-consultant, sales-manager, manufacturing, enterprise-application-development, pega-cloud, dx-api, government, insurance, consumer-services, other-industry, business-architect, communications-and-media, financial-services, team-lead, pega-delivery-leader, dev-designer-studio, cross-industry, healthcare-and-life-sciences, all-products, ui-solutions-developer, solutions-consulting-manager, pega-infinity, solutions-consultant, solutions-engineer, security, data-integration, data-management, data-model, senior-system-architect, lead-system-architect, case-management, system-architect\
**Created:** [May 14, 2025, 10:27am UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477 "2025-05-14T10:27:30Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Will\_Cho](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/will_cho/32/23260_2.png) [@Will\_Cho](https://forums.pega.com/u/Will_Cho)\
**Post date:** [May 14, 2025, 10:27am UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477/1 "2025-05-14T10:27:30Z")

</div>

This knowledge sharing article shows an implementation pattern of calling a Pega API, which requires an OAuth 2.0 authentication. It shows how to generate an OAuth 2.0 access token and how to call a Pega API using the access token to auto create cases in Pega application.

**Client use case**

This is a **technical user story.** Client wants to unit test a Pega API (POST/cases) to create a new case in Pega application. Client requires to use **OAuth 2.0 authentication** method when invoking the API. In practice, an external system will invoke the Pega API to automatically create cases.

**Configurations**

The configurations are organized into three parts:

1. Configure an OAuth 2.0 Client Registration instance in Pega.
2. Generate an OAuth 2.0 access token (using Postman)
3. Call Pega API - POST/cases (using Postman)

(**Part A - Configure an OAuth 2.0 Client Registration instance in Pega)**

**Step 1** - Create a new OAuth 2.0 Client Registration instance in DEV Studio.

In this example, we specified an Operator ID in the client credentials section. This Operator ID is mapped to an access group that has access to the case type.

Click to regenerate the client secret and download the client credentials file.

 ![34.png](https://pega1.discourse-cdn.com/pega/original/2X/b/b46828ed20561f9a665053f91c58c9c6f5520c7a.png)

**Step 2** - Save the instance.

**(Part B - Generate an OAuth 2.0 access token (using Postman))**

**Step 1** - Copy the **Access token endpoint** value from the client credentials file generated above.

 ![22.png](https://pega1.discourse-cdn.com/pega/original/2X/8/8247c27532982315d25f4afd3b95fae9c60bb378.png)

**Step 2** - Configure a Postman request to invoke the access token endpoint.

Set the URL and the key-value pair under Headers.

 ![07.png](https://pega1.discourse-cdn.com/pega/original/2X/9/90f90f4f18591fa0cea01e82793dd555d30dfff5.png)

Set the key-value pairs under Body.

- **client\_id** and **client\_secret** can be copied from the client credential file.

 ![36.png](https://pega1.discourse-cdn.com/pega/original/2X/8/8c46f01b9e0a885d3f85f8ff6257fa25ab18422c.png)

**Step 3** - Click Send to generate an access token.

 ![07.png](https://pega1.discourse-cdn.com/pega/original/2X/a/a5854b789e91a421373fa4664c76d4aac8846f8a.png)

(Note: if you received an “ **Cloud Agent Error: Couldn’t resolve host.** ” error, switch from Cloud Agent to Desktop Agent in Postman. The **Desktop Agent** runs locally on your machine and can access internal networks. Go to the bottom-right of Postman where it shows the agent selector and choose “Desktop Agent”)

Go to **[jwt.io](http://jwt.io)** and copy & paste the access token string to decode. As we can see, the decoded information shows the same Operator ID ([will.cho@pega.com](mailto:will.cho@pega.com)) that we specified in the OAuth 2.0 client registration above.

 ![59.png](https://pega1.discourse-cdn.com/pega/original/2X/8/88fdeea5577faae9f9d0499dbafa07b2da7056d3.png)

**(Part C - Call Pega API - POST/cases (using Postman))**

**Step 1** - Configure the **Authorization** settings\*\*.\*\*

- Select POST and enter the URL for Pega API (cases)
- Click the Authorization tab.
- Select **‘OAuth 2.0’** in the Auth Type dropdown.
- Copy and paste the **access token** as shown below\*\*.\*\*

 ![40.png](https://pega1.discourse-cdn.com/pega/original/2X/e/e3194324b04b37cbcab5dce79d369b23ee708ca3.png)

**Step 2** - Specify the Request data and click Send to get a successful response

 ![11.png](https://pega1.discourse-cdn.com/pega/original/2X/9/9c20d35058419b54fca49a75ceebefdafdfcbc79.png)

**Step 3** - Verify that the APP-2005 case is created successfully in Pega.

 ![55.png](https://pega1.discourse-cdn.com/pega/original/2X/2/2b520fb59216158c49ee817ab78fa34064cce44e.png)

**Additional information**

- Note that the **api** service is set to require OAuth 2.0 authentication.

 ![07.png](https://pega1.discourse-cdn.com/pega/original/2X/7/77d71a4bdb11d1c62edd659632db4a4c6bf53010.png)​

Please feel free to leave any comment or question.

**Constellation 101 Series**

Enjoyed this article? See more similar articles in [Constellation 101](https://support.pega.com/discussion/constellation-101) series.

---

<div class="post-metadata">

**Author:** ![Michel\_Kraaij](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/michel_kraaij/32/13235_2.png) [@Michel\_Kraaij](https://forums.pega.com/u/Michel_Kraaij)\
**Post date:** [May 14, 2025, 12:15pm UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477/2 "2025-05-14T12:15:47Z")

</div>

@Will Cho Thanks for this insight!

Just FYI, if anyone is interested in more in depth knowledge on how to use the Pega Constellation DX APIs (and, for example, how to utilize the APIs for software testing), reach out to the Pega Academy. They have a dedicated course on this topic.

(Or reach out to me. I’m one of the trainers 😉)

---

<div class="post-metadata">

**Author:** ![KamilJaneczek](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/kamiljaneczek/32/23339_2.png) [@KamilJaneczek](https://forums.pega.com/u/KamilJaneczek)\
**Post date:** [May 30, 2025, 8:23am UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477/3 "2025-05-30T08:23:59Z")

</div>

@Will ChoThanks for sharing. For those that want to check how we can authenticated from JavaScript using Oauth2, here is example: [c11n-testing/lib/utils.ts at main · kamiljaneczek/c11n-testing · GitHub](https://github.com/kamiljaneczek/c11n-testing/blob/main/lib/utils.ts)

---

<div class="post-metadata">

**Author:** ![Franz\_H](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/franz_h/32/23524_2.png) [@Franz\_H](https://forums.pega.com/u/Franz_H)\
**Post date:** [July 2, 2025, 6:55am UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477/4 "2025-07-02T06:55:53Z")

</div>

@Will ChoMany thanks for this article!

In my opinion, a deeper dive into the different grant types could be a great addition for a version 2. 🙂

---

<div class="post-metadata">

**Author:** ![Will\_Cho](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/will_cho/32/23260_2.png) [@Will\_Cho](https://forums.pega.com/u/Will_Cho)\
**Post date:** [August 7, 2025, 7:38pm UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477/5 "2025-08-07T19:38:06Z")

</div>

@DaniV17021618 Do you have a local login URL that doesn’t go through SSO? I would try that if available. I haven’t encountered 401 error when i did the demo above. If nothing works, i’d suggest to raise a Pega incident ticket.

---

<div class="post-metadata">

**Author:** ![JBRaghuraamm](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/jbraghuraamm/32/23263_2.png) [@JBRaghuraamm](https://forums.pega.com/u/JBRaghuraamm)\
**Post date:** [August 18, 2025, 5:43pm UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477/6 "2025-08-18T17:43:33Z")

</div>

@Will Cho how to use the dx api of an application from another pega constellation application , A and B are two pega parallel constellation applications , say if A wants to use B’ resources like getting data or like in your example to create a case. assume A and B are in same pega environment.

---

<div class="post-metadata">

**Author:** ![DennyV17768642](https://avatars.discourse-cdn.com/v4/letter/d/ea666f/32.png) [@DennyV17768642](https://forums.pega.com/u/DennyV17768642)\
**Post date:** [September 7, 2025, 9:50am UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477/7 "2025-09-07T09:50:31Z")

</div>

@Will Cho For DX API v2 too, same OAuth implementation you tried ?

---

<div class="post-metadata">

**Author:** ![DennyV17768642](https://avatars.discourse-cdn.com/v4/letter/d/ea666f/32.png) [@DennyV17768642](https://forums.pega.com/u/DennyV17768642)\
**Post date:** [September 16, 2025, 5:35pm UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477/8 "2025-09-16T17:35:55Z")

</div>

@Will Cho Thanks..

Also can you please share some insight on how to use authorization code instead of token credentials in DX API OAuth ? I’m looking for some details which i can try implment in community edition ?

---

<div class="post-metadata">

**Author:** ![DaniV17021618](https://avatars.discourse-cdn.com/v4/letter/d/85f322/32.png) [@DaniV17021618](https://forums.pega.com/u/DaniV17021618)\
**Post date:** [July 29, 2025, 1:40pm UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477/9 "2025-07-29T13:40:31Z")

</div>

@Will Cho

Hi Will, I have followed your tutorial but I get a 401 Unauthorized error when I try to generate a token in Step 3. I have tried my operator id and different access groups I am part of but still get a 401 error. My team’s application uses SSO and I think this may be causing the issue. Do you have any advice/tips on how to handle this kind of issue? Thank you

Access token endpoint: https:// **sso** {server}/prweb/PRRestService/oauth2/v1/token

---

<div class="post-metadata">

**Author:** ![JBRaghuraamm](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/jbraghuraamm/32/23263_2.png) [@JBRaghuraamm](https://forums.pega.com/u/JBRaghuraamm)\
**Post date:** [August 19, 2025, 5:00am UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477/10 "2025-08-19T05:00:24Z")

</div>

@Franz Hyes, I do agree with you, a detailed article on grant types is much helpful

---

<div class="post-metadata">

**Author:** ![Will\_Cho](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/will_cho/32/23260_2.png) [@Will\_Cho](https://forums.pega.com/u/Will_Cho)\
**Post date:** [September 12, 2025, 12:34am UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477/11 "2025-09-12T00:34:47Z")

</div>

@Denny Varghese DX API v2 should also support OAuth2.0

---

<div class="post-metadata">

**Author:** ![DennyV17768642](https://avatars.discourse-cdn.com/v4/letter/d/ea666f/32.png) [@DennyV17768642](https://forums.pega.com/u/DennyV17768642)\
**Post date:** [September 20, 2025, 11:13am UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477/12 "2025-09-20T11:13:49Z")

</div>

@Will Cho Thanks for guiding. I have created the question below. Please respond if you have any inputs.

[https://support.pega.com/question/dx-api-oauth-20-authorization-code-implementation](https://support.pega.com/question/dx-api-oauth-20-authorization-code-implementation)

---

<div class="post-metadata">

**Author:** ![Anoop\_Krishna](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/anoop_krishna/32/23458_2.png) [@Anoop\_Krishna](https://forums.pega.com/u/Anoop_Krishna)\
**Post date:** [January 29, 2026, 4:39pm UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477/13 "2026-01-29T16:39:40Z")

</div>

@Kamil Janeczek The URL you have provided is not working. Can you please provide the latest working URL

---

<div class="post-metadata">

**Author:** ![Will\_Cho](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/will_cho/32/23260_2.png) [@Will\_Cho](https://forums.pega.com/u/Will_Cho)\
**Post date:** [August 19, 2025, 12:17pm UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477/14 "2025-08-19T12:17:37Z")

</div>

@JBRaghuraamm There is a rich set of Pega APIs you can use.. including to get data from another Pega application. I normally first try that in Pega API landing page or using other API client tool like Postman/Bruno to test and learn how to use each API.

---

<div class="post-metadata">

**Author:** ![Will\_Cho](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/will_cho/32/23260_2.png) [@Will\_Cho](https://forums.pega.com/u/Will_Cho)\
**Post date:** [September 19, 2025, 11:41am UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477/15 "2025-09-19T11:41:48Z")

</div>

@Denny Varghese Thanks for your inquiry. This article posting is more focusing on OAuth 2.0 access token. Would you be able to create a separate Question posting with the question and more details about the authorization code? If I have any relevant knowldege, i’ll also provide my inputs or others should be able to help, too.

---

<div class="post-metadata">

**Author:** ![DennyV17768642](https://avatars.discourse-cdn.com/v4/letter/d/ea666f/32.png) [@DennyV17768642](https://forums.pega.com/u/DennyV17768642)\
**Post date:** [September 25, 2025, 10:34am UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477/16 "2025-09-25T10:34:25Z")

</div>

@Will Cho Hello ,

Could you please help on the latest question I asked ?

---

<div class="post-metadata">

**Author:** ![Will\_Cho](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/will_cho/32/23260_2.png) [@Will\_Cho](https://forums.pega.com/u/Will_Cho)\
**Post date:** [January 29, 2026, 7:07pm UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477/17 "2026-01-29T19:07:54Z")

</div>

@Denny Varghese Sorry, i may have missed your inquiry. I haven’t used the authorization code, but I did some Copilot search on internal Pega documents. Please validate before use.

“If you’re building a **Connect REST** rule (server‑to‑server, no user), don’t use Authorization Code—use a **confidential client** flow like **Client Credentials** or **JWT Bearer** instead. Those are intended for headless connectors and service accounts. Authorization Code is overkill there and requires an interactive user redirect”

---

<div class="post-metadata">

**Author:** ![MadhuSudan\_Kaka](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@MadhuSudan\_Kaka](https://forums.pega.com/u/MadhuSudan_Kaka)\
**Post date:** [March 7, 2026, 4:00am UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477/18 "2026-03-07T04:00:05Z")

</div>

Hi Will do,

Thanks for the detailed setup, I am trying to generate for Pega Access Token for new users whose Operator IDs do not yet exist in Pega. The user identity comes from JWT (sid).

## Current Configuration

Client Registration (JWT Bearer)

- JWT validation works (signature + standard claims OK).

### Token Profile

**Claims validation**

- iss → Constant (IdP identifier)

- aud → Constant (token endpoint)

- sub → Incoming claim; Compare = blank (we do not validate sub value)

**Claims mapping**

- sid → pySubject (and optionally also pxRequestor.pyUserIdentifier for logging)

- exp → (epoch seconds mapped appropriately)

**Identity Mapping → Post‑processing activity** (Applies‑To: `Data-Admin-Operator-ID`)

- Reads the user ID from claims (.pySubject or .pxRequestor.pyUserIdentifier)

- If operator does not exist:

Even after creating the operator and setting pySubject on Primary, we are getting:

ERROR … IdentityMapper: Unable to retrieve Operator Page ERROR … JWTIdentityMapper: No operator is associated with the token com.pega.pegarules.integration.engine.internal.services.IdentityMapperException: No operator is associated with the token

Appreciate any pointers, examples, or confirmation of the recommended pattern in 25.1.1. Happy to share a sanitized ruleset snippet if needed.

---

<div class="post-metadata">

**Author:** ![Will\_Cho](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/will_cho/32/23260_2.png) [@Will\_Cho](https://forums.pega.com/u/Will_Cho)\
**Post date:** [March 9, 2026, 12:09pm UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477/19 "2026-03-09T12:09:56Z")

</div>

Thanks for the question. I haven’t worked on the scenario where Operator ID does not exist and may not have a definitive answer.

One thing I can think of is.. maybe try the access group option in the Client credentials (instead of OperatorID) and see what happens.

 ![image](https://pega1.discourse-cdn.com/pega/original/3X/0/1/01da28e96a1f003735ab639483c8c0a765b3dbe0.png)

Besides, I asked Copilot to search internal documents and provide inputs. Please find the attachment and see if you get any useful pointer.

[Copilot response.docx](https://forums.pega.com/uploads/short-url/5vUbxgbzBLaEKYFFAzny0ejh26M.docx) (19.2 KB)

---

<div class="post-metadata">

**Author:** ![MadhuSudan\_Kaka](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@MadhuSudan\_Kaka](https://forums.pega.com/u/MadhuSudan_Kaka)\
**Post date:** [March 10, 2026, 12:48am UTC](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477/20 "2026-03-10T00:48:19Z")

</div>

Hi Will,

Thank you for taking the time to look into this and share the insights, really appreciate it.  
On the Access Group in Client Credentials suggestion: in our case, user entitlements vary by user, so a single static AG wouldn’t produce tokens with the correct fine‑grained access. We need the token to reflect per-user entitlements, which for us means resolving to (or deriving from) a specific Operator ID rather than a shared AG.

Questions for anyone who has solved this in Infinity:

Is there a supported pattern to issue JWT Bearer tokens when the Operator doesn’t yet exist—without using a single static AG?

If someone has a working configuration where Identity Mapping creates an operator and the token is still issued in the same call, what was the minimal set of pages/parameters you populated to satisfy the identity mapper (e.g., did you map the identifier to .pyUserIdentifier on the Operator page and return that page as the mapper expects)?

Thanks again for the pointers—super helpful to narrow the viable patterns.

[Next page](https://forums.pega.com/t/how-to-create-oauth-2-0-access-token-to-call-pega-api/9477.md?page=2)
