Use oauth token to create GitHub project if available

Make sure you have repo/public_repo and write:org scopes.

Change-Id: I773331d2b0051865d783af5024fac1490c64c782
This commit is contained in:
Mathieu Gagné 2016-02-08 13:29:35 -05:00
parent a2d4e2f92f
commit 6d97045c8c
1 changed files with 5 additions and 3 deletions

View File

@ -276,9 +276,11 @@ def create_github_project(
secure_config = ConfigParser.ConfigParser()
secure_config.read(github_secure_config)
# Project creation doesn't work via oauth
ghub = github.Github(secure_config.get("github", "username"),
secure_config.get("github", "password"))
if secure_config.has_option("github", "oauth_token"):
ghub = github.Github(secure_config.get("github", "oauth_token"))
else:
ghub = github.Github(secure_config.get("github", "username"),
secure_config.get("github", "password"))
orgs = ghub.get_user().get_orgs()
orgs_dict = dict(zip([o.login.lower() for o in orgs], orgs))