1

I am having trouble finding a way to request "repo" scope when authorizing a user in OAuth using the PyGithub library.

My team is building a "repository analyzer" website that provides insights on code in a chosen repository. We are using the PyGithub implementation of the Git API. We are using OAuth to authorize users and it works great for public repositories. However, I am unable to succesfully specify a scope. I tried "Github.oauth_scopes" below which is obviously wrong. Any tips are greatly appreciated!

In the screenshot can see that OAuth is only requesting public data, we need to prompt access to private repositories too which means using the "repo" scope: GitApiScopeDoc

from github import *

g = Github()

#request repo scope
Github.oauth_scopes = "repo"

#authorization using oauth
clientID = "enterclientidhere"
secret = "entersecrethere"
oauth = g.get_oauth_application(clientID, secret)
url = oauth.get_login_url()

#print the url, then we follow the url to github which requests a users identity
print(url)

screenshot

1 Answers1

0

from github import *

g = Github()

#request repo scope
Github.scopes = "repo"

#authorization using oauth
clientID = "enterclientidhere"
secret = "entersecrethere"
oauth = g.get_oauth_application(clientID, secret)
url = oauth.get_login_url()

#print the url, then we follow the url to github which requests a users identity
print(url)

The code above should work. You sh