# How to get a GitHub OAuth 2.0 access token using Keycloak Token Management API

**URL:** <https://forum.keycloak.org/t/how-to-get-a-github-oauth-2-0-access-token-using-keycloak-token-management-api/20397>\
**Category:** Getting advice\
**Created:** [February 21, 2023, 7:22am UTC](https://forum.keycloak.org/t/how-to-get-a-github-oauth-2-0-access-token-using-keycloak-token-management-api/20397 "2023-02-21T07:22:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![oha95](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/oha95/32/7346_2.png) [@oha95](https://forum.keycloak.org/u/oha95)\
**Post date:** [February 21, 2023, 7:22am UTC](https://forum.keycloak.org/t/how-to-get-a-github-oauth-2-0-access-token-using-keycloak-token-management-api/20397/1 "2023-02-21T07:22:26Z")

</div>

Hello Keycloak community,

I am trying to get a GitHub OAuth 2.0 access token using the Keycloak Token Management API, but I am having some difficulties.

I have followed the documentation and set up an identity provider for GitHub in Keycloak, and I am able to successfully authenticate users with their GitHub accounts. However, I am not sure how to use the Keycloak Token Management API to get a GitHub access token that I can use to access the GitHub API on behalf of the authenticated user.

I have tried using the “urn:ietf:params:oauth:grant-type:token-exchange” grant type and specifying “[https://api.github.com](https://api.github.com/)” as the “resource” in my request for a delegated access token, but I get an error saying “Feature not enabled”.

Could someone please help me understand how to use the Keycloak Token Management API to get a GitHub access token?

Thank you in advance for any help you can provide!

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [February 21, 2023, 5:50pm UTC](https://forum.keycloak.org/t/how-to-get-a-github-oauth-2-0-access-token-using-keycloak-token-management-api/20397/2 "2023-02-21T17:50:55Z")

</div>

Documentation on retrieving external IDP tokens is here:  
[https://www.keycloak.org/docs/latest/server\_development/index.html#retrieving-external-idp-tokens](https://www.keycloak.org/docs/latest/server_development/index.html#retrieving-external-idp-tokens)
