8000 Optional-ised `Github.authorize` scope argument · Lukasa/github3.py@d6cf634 · GitHub
[go: up one dir, main page]

Skip to content

Commit d6cf634

Browse files
Optional-ised Github.authorize scope argument
1 parent 87a0e90 commit d6cf634

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

github3/github.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ def authorization(self, id_num):
8181
json = self._json(self._get(url), 200)
8282
return Authorization(json, self) if json else None
8383

84-
def authorize(self, login, password, scopes, note='', note_url='',
84+
def authorize(self, login, password, scopes=None, note='', note_url='',
8585
client_id='', client_secret=''):
8686
"""Obtain an authorization token from the GitHub API for the GitHub
8787
API.
8888
8989
:param str login: (required)
9090
:param str password: (required)
91-
:param list scopes: (required), areas you want this token to apply to,
91+
:param list scopes: (optional), areas you want this token to apply to,
9292
i.e., 'gist', 'user'
9393
:param str note: (optional), note about the authorization
9494
:param str note_url: (optional), url for the application
@@ -100,10 +100,12 @@ def authorize(self, login, password, scopes, note='', note_url='',
100100
"""
101101
json = None
102102
auth = self._session.auth or (login and password)
103-
if isinstance(scopes, list) and auth:
103+
if auth:
104104
url = self._build_url('authorizations')
105-
data = {'scopes': scopes, 'note': note, 'note_url': note_url,
105+
data = {'note': note, 'note_url': note_url,
106106
'client_id': client_id, 'client_secret': client_secret}
107+
if scopes:
108+
data['scopes'] = scopes
107109
if self._session.auth:
108110
json = self._json(self._post(url, data=data), 201)
109111
else:

0 commit comments

Comments
 (0)
0