ahadik / git_mover

A Python script to migrate milestones, labels, and issues between repositories.
51 stars 42 forks source link

does not work with personal access tokens #9

Open simevo opened 6 years ago

simevo commented 6 years ago

fails with 401

simevo commented 6 years ago

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 ?

bwindels commented 4 years ago

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 commented 4 years ago

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