# Get custom claims from different server on a REST call

**URL:** <https://devforum.okta.com/t/get-custom-claims-from-different-server-on-a-rest-call/23141>\
**Category:** OAuth/OIDC\
**Created:** [January 24, 2023, 7:29pm UTC](https://devforum.okta.com/t/get-custom-claims-from-different-server-on-a-rest-call/23141 "2023-01-24T19:29:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tgkumarmca](https://avatars.discourse-cdn.com/v4/letter/t/e9bcb4/32.png) [@tgkumarmca](https://devforum.okta.com/u/tgkumarmca)\
**Post date:** [January 24, 2023, 7:29pm UTC](https://devforum.okta.com/t/get-custom-claims-from-different-server-on-a-rest-call/23141/1 "2023-01-24T19:29:05Z")

</div>

Dear Team,

I am working on a use-case where my application needs to get the access token generated by okta using authorization\_code grant type. That token should contain the custom attribute. We need to determine the custom attribute for the user from different application where the application has the REST endpoint to retrieve the value. Kindly help me to get the custom attribute and inject it into the token. That custom attribute needs to be reused in subsequent API calls.

the sequence flow has been attached for more understanding of the flow expected in the usecase

 ![Screenshot 2023-01-24 at 1.26.21 PM](https://global.discourse-cdn.com/oktadev/original/2X/1/1c64e9e7b2273f5275c2878fd8a8da1b98848d58.png)

---

<div class="post-metadata">

**Author:** ![sigama](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/sigama/32/5811_2.png) [@sigama](https://devforum.okta.com/u/sigama)\
**Post date:** [January 24, 2023, 9:28pm UTC](https://devforum.okta.com/t/get-custom-claims-from-different-server-on-a-rest-call/23141/2 "2023-01-24T21:28:02Z")

</div>

Hi @tgkumarmca! You may consider [Token Inline Hook](https://developer.okta.com/docs/reference/token-hook/) -

> This type of inline hook is triggered when OAuth 2.0 and OpenID Connect (OIDC) tokens are minted by your Okta Custom Authorization Server. Before sending the token to the requester, Okta calls out to your external service, and your service can respond with commands to add custom claims to the token or to modify existing claims.

Here is an example - [Use Okta Token Hooks to Supercharge OpenID Connect | Okta Developer](https://developer.okta.com/blog/2019/12/23/extend-oidc-okta-token-hooks)

---

<div class="post-metadata">

**Author:** ![tgkumarmca](https://avatars.discourse-cdn.com/v4/letter/t/e9bcb4/32.png) [@tgkumarmca](https://devforum.okta.com/u/tgkumarmca)\
**Post date:** [January 25, 2023, 2:44am UTC](https://devforum.okta.com/t/get-custom-claims-from-different-server-on-a-rest-call/23141/3 "2023-01-25T02:44:18Z")

</div>

Thanks for the reply! I was able to test with the token webhooks. This is working as per the requirement in success case. I would like to throw an exception when the hook is failed to execute. With this current implementation, token is being generated even the hook failed. How can I handle this exception scenario?

---

<div class="post-metadata">

**Author:** ![sigama](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/sigama/32/5811_2.png) [@sigama](https://devforum.okta.com/u/sigama)\
**Post date:** [January 26, 2023, 12:41am UTC](https://devforum.okta.com/t/get-custom-claims-from-different-server-on-a-rest-call/23141/4 "2023-01-26T00:41:35Z")

</div>

@tgkumarmca good to hear this meets your needs. Unfortunately, we don’t have a way to handle an exception to your hook failed scenario ☹ you may want to post on our [Ideas Page](https://ideas.okta.com/) for our product team to consider this option.

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 13, 2024, 7:46pm UTC](https://devforum.okta.com/t/get-custom-claims-from-different-server-on-a-rest-call/23141/5 "2024-02-13T19:46:12Z")

</div>


