# Using Gitea as oauth2 provider for Portainer

**URL:** <https://forum.gitea.com/t/using-gitea-as-oauth2-provider-for-portainer/7062>\
**Category:** Install/Maintain/Configure\
**Created:** [April 13, 2023, 1:35am UTC](https://forum.gitea.com/t/using-gitea-as-oauth2-provider-for-portainer/7062 "2023-04-13T01:35:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikolai-in](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/nikolai-in/32/5104_2.png) [@nikolai-in](https://forum.gitea.com/u/nikolai-in)\
**Post date:** [April 13, 2023, 1:35am UTC](https://forum.gitea.com/t/using-gitea-as-oauth2-provider-for-portainer/7062/1 "2023-04-13T01:35:57Z")

</div>

Hello everyone,  
I need some help with configuring Gitea as an OAuth2 provider for Portainer. I have followed the steps listed below:

1. Installed and configured Gitea on my server using docker
2. Configured Portainer to use custom OAuth provider
3. Created an OAuth2 application in Gitea with the correct redirect URI for Portainer
4. Entered the client ID and client secret from Gitea into the Portainer settings

However, when I try to log in to Portainer using my Gitea credentials, I get an error message saying “Failure Unauthorized” and “Unable to login via OAuth”. I also see an error 500 in the browser console with the message “`{data: {message: "Unable to authenticate through OAuth", details: "Unauthorized"}, status: 500, headers: function, config: Object, statusText: "", …}`”.

I’m not sure what I’m doing wrong, but I suspect that there might be an issue with the way I’ve configured the OAuth2 application in Gitea or the Portainer settings.

If anyone has experience with configuring Gitea as an OAuth2 provider for Portainer and has encountered this issue before, I would greatly appreciate any advice or guidance you can offer.  
Thank you in advance for your help!

 ![Screenshot 2023-04-13 at 04.32.31](https://us1.discourse-cdn.com/flex020/uploads/gitea/original/2X/5/509c2bcefd6a50242bec9fcfa66394e10401f57b.png)

---

<div class="post-metadata">

**Author:** ![m42e](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@m42e](https://forum.gitea.com/u/m42e)\
**Post date:** [April 13, 2023, 2:08pm UTC](https://forum.gitea.com/t/using-gitea-as-oauth2-provider-for-portainer/7062/2 "2023-04-13T14:08:26Z")

</div>

Try it like this:

 ![Bildschirmfoto 2023-04-13 um 10.47.11](https://us1.discourse-cdn.com/flex020/uploads/gitea/original/2X/6/659f51c8dff124ad551bb24e0b64c86d7258361e.png)

---

<div class="post-metadata">

**Author:** ![nikolai-in](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/nikolai-in/32/5104_2.png) [@nikolai-in](https://forum.gitea.com/u/nikolai-in)\
**Post date:** [April 13, 2023, 2:53pm UTC](https://forum.gitea.com/t/using-gitea-as-oauth2-provider-for-portainer/7062/3 "2023-04-13T14:53:00Z")

</div>

Fixed it, I had a self-signed certificate, and it needed to be mounted like `/opt/my-ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt` and it **has to be** `.crt`. It also helped to add `command: --log-level=DEBUG` to Portainer’s docker compose.

---

<div class="post-metadata">

**Author:** ![nikolai-in](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/nikolai-in/32/5104_2.png) [@nikolai-in](https://forum.gitea.com/u/nikolai-in)\
**Post date:** [April 13, 2023, 2:56pm UTC](https://forum.gitea.com/t/using-gitea-as-oauth2-provider-for-portainer/7062/4 "2023-04-13T14:56:14Z")

</div>

Thank you, that helped too. 😀
