So this should be pretty simple, but I can't seem to find my fail point. Hopefully someone else can point it out to me.
First I go to https://github.com/login/oauth/authorize?client_id=CLIENT_ID&scope=gist
and this returns a code to me. Then I do this:
import requests, json
client_id = XXXX
client_secret = XXXX
code = XXXX
r = requests.post(
'https://github.com/login/oauth/access_token',
data=json.dumps({
'client_id':client_id,
'client_secret':client_secret,
'code':code
})
r.content # this gives me a 404 header
When I go to my test user it shows me as authorized and my app shows as having one user, but I don't have a access token.
What am I doing wrong.
Well I was right this was a really simple problem, but I'll leave this here incase others run into the same error.
When in doubt manually define your header. So you need:
header = {'content-type':'application/json'}
And then pass in the header:
r = requests.post(
'https://github.com/login/oauth/access_token',
data=json.dumps({
'client_id':client_id,
'client_secret':client_secret,
'code':code
}),
headers=header
)
For me this solved the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With