It is not possible to access Gitea API using token, issued by external oauth2 provider (e.g. Keycloak) #6304

Closed
opened 2025-11-02 06:51:38 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @daniil-pankratov on GitHub (Nov 12, 2020).

  • Gitea version (or commit ref): 1.12.5
  • Git version:
  • Operating system:
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
  • Log gist:

Description

...

Screenshots

Originally created by @daniil-pankratov on GitHub (Nov 12, 2020). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.12.5 - Git version: - Operating system: <!-- Please include information on whether you built gitea yourself, used one of our downloads or are using some other package --> <!-- Please also tell us how you are running gitea, e.g. if it is being run from docker, a command-line, systemd etc. ---> <!-- If you are using a package or systemd tell us what distribution you are using --> - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - Log gist: <!-- It really is important to provide pertinent logs --> <!-- Please read https://docs.gitea.io/en-us/logging-configuration/#debugging-problems --> <!-- In addition, if your problem relates to git commands set `RUN_MODE=dev` at the top of app.ini --> ## Description ... ## Screenshots <!-- **If this issue involves the Web Interface, please include a screenshot** -->
GiteaMirror added the type/question label 2025-11-02 06:51:38 -06:00
Author
Owner

@dfelski commented on GitHub (Nov 12, 2020):

I have exactly the same issue. A Keycloak instance is running as OAuth2 authentication source and the web UI access works fine, but Restful API calls using bearer token are always answered with "unauthorized".

@dfelski commented on GitHub (Nov 12, 2020): I have exactly the same issue. A Keycloak instance is running as OAuth2 authentication source and the web UI access works fine, but Restful API calls using bearer token are always answered with "unauthorized".
Author
Owner

@6543 commented on GitHub (Nov 14, 2020):

I'm not sure - never tryed

@6543 commented on GitHub (Nov 14, 2020): I'm not sure - never tryed
Author
Owner

@techknowlogick commented on GitHub (Nov 15, 2020):

Keycloak doesn't generate Gitea API tokens. Just like you wouldn't expect Twitter API tokens to work with Gitea. If they did we would have to pass each token provided to us upstream to each external auth system to verify the token is valid.

If you would like passthrough authentication I recommend looking at using LDAP.

@techknowlogick commented on GitHub (Nov 15, 2020): Keycloak doesn't generate Gitea API tokens. Just like you wouldn't expect Twitter API tokens to work with Gitea. If they did we would have to pass each token provided to us upstream to each external auth system to verify the token is valid. If you would like passthrough authentication I recommend looking at using LDAP.
Author
Owner

@dfelski commented on GitHub (Nov 16, 2020):

But Twitter doesn't support authentication via external OAuth2 provider, right? What's the issue with the usage of the access tokens here like the UI does?

@dfelski commented on GitHub (Nov 16, 2020): But Twitter doesn't support authentication via external OAuth2 provider, right? What's the issue with the usage of the access tokens here like the UI does?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6304