# Use OIDC through REST API

**URL:** https://meta.discourse.org/t/use-oidc-through-rest-api/247936
**Category:** SSO
**Tags:** openid-connect, rest-api
**Created:** [December 6, 2022, 6:01am UTC](https://meta.discourse.org/t/use-oidc-through-rest-api/247936 "2022-12-06T06:01:03Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mohit\_kumar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mohit_kumar/32/284559_2.png) [@mohit\_kumar](https://meta.discourse.org/u/mohit_kumar)
#### Post date: [December 6, 2022, 6:01am UTC](https://meta.discourse.org/t/use-oidc-through-rest-api/247936/1 "2022-12-06T06:01:03Z")

</div>

Hi All,

I have setup OIDC and Keycloak, through browser I am able to integrate Discourse, OIDC and Keycloak properly  
I want to use API for creating/reply posts on behalf of users. For this I want to get the token from keycloak and use it in discourse (Don’t want users login to discourse seperately). Any help what api should I call and how to achieve this ?

From UI I can see additional fields comes after login i.e CSRF token and cookie and the complete flow works fine. I want to acheive same but through API without any UI interference.

Any leads will be appreciated.

Thank you

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 6, 2022, 5:04pm UTC](https://meta.discourse.org/t/use-oidc-through-rest-api/247936/2 "2022-12-06T17:04:09Z")

</div>

> [@mohit\_kumar](#):
>
> I want to use API for creating/reply posts on behalf of users.

Just use a global token that works for any user. You can retrieve user tokens only once.
