def authorize(self, login, password, scopes, note='', note_url='', client_id='', client_secret=''): """Obtain an authorization token from the GitHub API for the GitHub API. :param str login: (required) :param str password: (required) :param list scopes: (required), areas you want this token to apply to, i.e., 'gist', 'user' :param str note: (optional), note about the authorization :param str note_url: (optional), url for the application :param str client_id: (optional), 20 character OAuth client key for which to create a token :param str client_secret: (optional), 40 character OAuth client secret for which to create the token :returns: :class:`Authorization <Authorization>` """ json = None auth = self._session.auth or (login and password) if isinstance(scopes, list) and auth: url = self._build_url('authorizations') data = {'scopes': scopes, 'note': note, 'note_url': note_url, 'client_id': client_id, 'client_secret': client_secret} if self._session.auth: json = self._json(self._post(url, data=data), 201) else: ses = session() ses.auth = (login, password) json = self._json(ses.post(url, data=dumps(data)), 201) return Authorization(json, self) if json else None
def authorization(self, id_num): """Get information about authorization ``id``. :param int id_num: (required), unique id of the authorization :returns: :class:`Authorization <Authorization>` """ json = None if int(id_num) > 0: url = self._build_url('authorizations', str(id_num)) json = self._json(self._get(url), 200) return Authorization(json, self) if json else None