Accessing the API with http header "Authorization" does not work #1627

Closed
opened 2025-11-02 04:07:27 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @ghost on GitHub (Mar 15, 2018).

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

Description

Accessing the API with http header "Authorization" does not work.

curl \
  --resolve gitea.net:3000:10.0.0.112 \
  -X GET \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  'http://gitea.net:3000/api/v1/repos/devs/tmv4/keys?token=4a40ddb4190802e39825f06ec8a04a4ba3af22bf'; echo
[]

The same for access_token=.
Using Authorization header:

curl \
  --resolve gitea.net:3000:10.0.0.112 \
  -X GET \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Authorization: 4a40ddb4190802e39825f06ec8a04a4ba3af22bf' \
  http://gitea.net:3000/api/v1/repos/devs/tmv4/keys; echo
{"message":"Only signed in user is allowed to call APIs."}

No helpfull information in Debug and Trace logs. (?)

Originally created by @ghost on GitHub (Mar 15, 2018). <!-- 1. Please speak English, this is the language all of us can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/NsatcWJ) 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.3.2 - Git version: 2.7.4 - Operating system: Ubuntu 16.04 - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [x] No (try.gitea.io is down) - [ ] Not relevant - Log gist: ## Description Accessing the API with http header "Authorization" does not work. ```bash curl \ --resolve gitea.net:3000:10.0.0.112 \ -X GET \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ 'http://gitea.net:3000/api/v1/repos/devs/tmv4/keys?token=4a40ddb4190802e39825f06ec8a04a4ba3af22bf'; echo ``` ```json [] ``` The same for access_token=. Using Authorization header: ```bash curl \ --resolve gitea.net:3000:10.0.0.112 \ -X GET \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: 4a40ddb4190802e39825f06ec8a04a4ba3af22bf' \ http://gitea.net:3000/api/v1/repos/devs/tmv4/keys; echo ``` ```json {"message":"Only signed in user is allowed to call APIs."} ``` No helpfull information in `Debug` and `Trace` logs. (?)
Author
Owner

@ghost commented on GitHub (Mar 15, 2018):

Reviewing the code revealed that providing -H 'Authorization: token 4a40ddb4190802e39825f06ec8a04a4ba3af22bf seems to work. This would be something which really required some documentation, I guess.

@ghost commented on GitHub (Mar 15, 2018): Reviewing the code revealed that providing ``-H 'Authorization: token 4a40ddb4190802e39825f06ec8a04a4ba3af22bf`` seems to work. This would be something which really required some documentation, I guess.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#1627