git_mover icon indicating copy to clipboard operation
git_mover copied to clipboard

does not work with personal access tokens

Open simevo opened this issue 7 years ago • 3 comments

fails with 401

simevo avatar Aug 23 '18 09:08 simevo

see https://developer.github.com/v3/#authentication

the user_name parameter is not used, and the OAuth2 token can be passed as a parameter with the url:

url = url + "&access_token=" + credentials['token']

PR ?

simevo avatar Aug 23 '18 09:08 simevo

My patch to make it work:

20c20,21
< 	r = requests.get(url=url, auth=(credentials['user_name'], credentials['token']), headers={'Content-type': 'application/json'})
---
> 	url = url + "&access_token=" + credentials['token']
> 	r = requests.get(url=url, headers={'Content-type': 'application/json'})
28c29,30
< 	r = requests.post(url=url, data=data, auth=(credentials['user_name'], credentials['token']), headers={'Content-type': 'application/json', 'Accept': 'application/vnd.github.v3.html+json'})
---
> 	url = url + "&access_token=" + credentials['token']
> 	r = requests.post(url=url, data=data, headers={'Content-type': 'application/json', 'Accept': 'application/vnd.github.v3.html+json'})
86c88
< 	url = destination_url+"repos/"+destination+"/milestones"
---
> 	url = destination_url+"repos/"+destination+"/milestones?"
136c138
< 	url = destination_url+"repos/"+destination+"/issues"
---
> 	url = destination_url+"repos/"+destination+"/issues?"
199c201
< 	destination_credentials = {'user_name': args.destinationUserName, 'token': args.destinationToken}
---
> 	destination_credentials = source_credentials

bwindels avatar Aug 18 '20 13:08 bwindels

This will stop working at some point though: https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param

bwindels avatar Aug 19 '20 07:08 bwindels