# Gitea REST API with OpenID Connect Token

**URL:** <https://forum.gitea.com/t/gitea-rest-api-with-openid-connect-token/6857>\
**Category:** General\
**Created:** [March 13, 2023, 1:12pm UTC](https://forum.gitea.com/t/gitea-rest-api-with-openid-connect-token/6857 "2023-03-13T13:12:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![johannes\_sg](https://avatars.discourse-cdn.com/v4/letter/j/5fc32e/32.png) [@johannes\_sg](https://forum.gitea.com/u/johannes_sg)\
**Post date:** [March 13, 2023, 1:12pm UTC](https://forum.gitea.com/t/gitea-rest-api-with-openid-connect-token/6857/1 "2023-03-13T13:12:28Z")

</div>

Hello,

We added an OpenID Connect (OAuth2) Authentication Source to our gitea instance and are wondering if it is possible to use the REST API with tokens generated by this external auth source?

If we try to do this using the “Authentication” header with value “token {token\_value}” we get status 401 - Unauthorized (we also tried “bearer {token\_value}”).

Any help or feedback is much appreciated,  
Thank you!

---

<div class="post-metadata">

**Author:** ![jake](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@jake](https://forum.gitea.com/u/jake)\
**Post date:** [March 13, 2023, 4:24pm UTC](https://forum.gitea.com/t/gitea-rest-api-with-openid-connect-token/6857/2 "2023-03-13T16:24:37Z")

</div>

I believe the API only works with API tokens or Gitea’s OAuth provider tokens. There is an issue on GitHub proposing the addition of using external authentication/authorization sources [Provide a way to access Gitea API through external authentication source · Issue #23382 · go-gitea/gitea · GitHub](https://github.com/go-gitea/gitea/issues/23382) but it was just created a few days ago.

A workaround I can think of is to make something like a “Gitea token generator” app that runs the user through Gitea’s OAuth2 provider workflow (which will send them to OpenID Connect before granting the token) and then shows the resulting token to them. See [API Auth w/ OAuth2 Provider](https://docs.gitea.io/en-us/api-usage/#oauth2-provider) and [OAuth2 Provider](https://docs.gitea.io/en-us/oauth2-provider/) docs for more info.

---

<div class="post-metadata">

**Author:** ![johannes\_sg](https://avatars.discourse-cdn.com/v4/letter/j/5fc32e/32.png) [@johannes\_sg](https://forum.gitea.com/u/johannes_sg)\
**Post date:** [March 13, 2023, 4:40pm UTC](https://forum.gitea.com/t/gitea-rest-api-with-openid-connect-token/6857/3 "2023-03-13T16:40:09Z")

</div>

Thank you very much for the information Jake! I was already afraid that it currently is not possible… We will see if we can do something like the workaround you propsed. We will also monitor the issue you linked.
