Starting example results in 404, should specify JWT to make it work
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 42/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- github, python
- Ambito
- api, authentication
Direzione di ricerca
Inizia riproducendo il semplice esempio di GhApi con token='' e confrontalo con jwt_token='' e con la richiesta curl di GitHub. Traccia il modo in cui GhApi costruisce l'header Authorization, quindi aggiorna l'esempio iniziale o le relative indicazioni sull'autenticazione in modo che api.pulls.list() non produca più il 404 segnalato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The simple example results in a 404 error:
api = GhApi(owner='owner', repo='repo', token='<YOUR-TOKEN>')
pulls = api.pulls.list()
but with curl it works (from GitHub docs):
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://api.github.com/repos/OWNER/REPO/pulls
The following works:
api = GhApi(owner='owner', repo='repo', jwt_token='<YOUR-TOKEN>')
pulls = api.pulls.list()
The personal access token has scopes for repo, workflow, gist and notifications.
Cause
It seems the API call to GitHub expects a different header. The example on GhApi sets Authorization: token <YOUR-TOKEN> but the example on GitHub specifies Authorization: Bearer <YOUR-TOKEN>. On https://docs.github.com/en/rest/overview/other-authentication-methods this is expanded upon with the note:
Note: In most cases, you can use Authorization: Bearer or Authorization: token to pass a token. However, if you are passing a JSON web token (JWT), you must use Authorization: Bearer.
Reading the docs I assume the header Authorization: token <TOKEN> is fine, but the above experimentation indicates otherwise.
Conclusion
I have no clue why 'my' token is regarded as a JWT token here, and in the example of GhApi not. For me it works, but I couldn't find a reason. Perhaps it helps someone searching for this, but I'm also interested to known if it is a setting or ...
- Lingua principale
- Python
- Stelle
- 687
- Fork
- 69
- Merge medio
- 1m
- PR unite (30g)
- 2
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di AnswerDotAI/ghapi
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
AnswerDotAI/ghapi#158 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
AnswerDotAI/ghapi#120 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 58/100
AnswerDotAI/ghapi#208 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
AnswerDotAI/ghapi#201 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
AnswerDotAI/ghapi#186 ·
Tutte le issue di AnswerDotAI/ghapi
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
xinnan-tech/xiaozhi-fde-talk#263 ·
-
rules
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
huggingface/Repo2RLEnv#163 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
huggingface/sentence-transformers#4074 ·
-
comp/dashboard invalid P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
NousResearch/hermes-agent#121143 ·