# Fetch Identity Provider token in protocol mapper

**URL:** <https://forum.keycloak.org/t/fetch-identity-provider-token-in-protocol-mapper/16081>\
**Category:** Extending the server\
**Tags:** identity-brokering, oidc\
**Created:** [June 21, 2022, 6:29pm UTC](https://forum.keycloak.org/t/fetch-identity-provider-token-in-protocol-mapper/16081 "2022-06-21T18:29:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![blabadi](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/blabadi/32/6032_2.png) [@blabadi](https://forum.keycloak.org/u/blabadi)\
**Post date:** [June 21, 2022, 6:29pm UTC](https://forum.keycloak.org/t/fetch-identity-provider-token-in-protocol-mapper/16081/1 "2022-06-21T18:29:37Z")

</div>

Hi

I have use case where I need to fetch extra information from an OIDC provider and add custom claims to the token keycloak generates.

I have wrote a custom Protocol Mapper and I’m stuck on how to fetch the IDP token (to do extra calls to the Idp) in the protocol mapper.

I know there is a keycloak API to read idp tokens but it needs to have the access token

Thanks

---

<div class="post-metadata">

**Author:** ![mercator](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@mercator](https://forum.keycloak.org/u/mercator)\
**Post date:** [January 12, 2023, 12:47am UTC](https://forum.keycloak.org/t/fetch-identity-provider-token-in-protocol-mapper/16081/2 "2023-01-12T00:47:23Z")

</div>

I know this is an old question but I’m stuck with the same problem. When exchanging an external IdP token for an internal one, my custom Protocol Mapper needs to read claims from the external token.
