Remove "resource" field from /auth/oauth/v2/token
search cancel

Remove "resource" field from /auth/oauth/v2/token

book

Article ID: 258505

calendar_today

Updated On: 05-27-2025

Products

CA API Gateway

Issue/Introduction

We use this token API to get the access-token. But in response we are seeing additional field "resource". We don't want the field. How do you removed the field " resource"?

{

    "access_token""",
    "token_type""Bearer",
    "expires_in"3600,
    "scope""oob",
    "resource": []
}

 

Environment

Gateway 10.1, 11.x

OTK 4.6.x

Resolution

There is a workaround that involves adding a context variable.

- Go to the endpoint: auth/oauth/v2/token  [OTK-> Server -> DMZ -> OAuth 2.0 -> TokenServer]

OTK 4.6.0
- Add “Set Context Variable” before the "Return Template Responses to Requestor" - currently Line 147 that excludes "resource"

clientResponse

{
  "access_token":"${at_token}",
  "token_type":"Bearer",
  "expires_in":${at_lifetime},
  "scope":"${scope.granted}"
}

 

Changes from:

{
    "access_token": "<ACCESS_TOKEN>",
    "token_type": "Bearer",
    "expires_in": 3600,
    "scope": "oob",
    "resource": [
        "https://GatewayHost/*"

    ]

}

TO:

{
    "access_token": "<ACCESS_TOKEN>",
    "token_type": "Bearer",
    "expires_in": 3600,
    "scope": "oob"
}

Screenshot from OTK 4.6.0

 

For 4.6.x,  there is a custom fragment called  #OTK token response.  Make modification for the fragment to add a Set Context Variable with the string as above image showed.  The fragment is included in the auth/oauth/v2/token policy and the return response value will be overwritten by the #OTK token response string. 

Additional Information

NOTE: This workaround will get overwritten when OTK is upgraded.