def oauth(self, code, state):
"""Handler for Authorization callback URL.
'code' and 'state' are GET variables given by github
:param string code:
:param string state:
:return: Client instance
:raises: exceptions.GithubException
"""
try:
scopes = self._requested_scopes.pop(state)
except KeyError:
raise UnknownState(state)
data = {
"client_id": self._client_id,
"client_secret": self._client_secret,
"code": code,
"state": state,
}
headers = {
"accept": "application/json"
}
response = yield from aiohttp.post(REQ_TOKEN_URL,
data=data,
headers=headers)
data = yield from response.json()
return Client(data["access_token"], scopes)
评论列表
文章目录