raise exceptions
This commit is contained in:
parent
4cb525ac11
commit
9899812fe7
@ -19,17 +19,17 @@ class YandexAuthView(BaseView):
|
|||||||
'code': code
|
'code': code
|
||||||
})
|
})
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
self.logger.warning("Cant access, json: %s", response.json())
|
raise Exception("Cant access, json: " + str(response.json()))
|
||||||
return '/welcome'
|
return '/welcome'
|
||||||
access_token = response.json().get('access_token')
|
access_token = response.json().get('access_token')
|
||||||
if access_token is None:
|
if access_token is None:
|
||||||
self.logger.warning('no access token')
|
raise Exception('no access token')
|
||||||
return '/welcome'
|
return '/welcome'
|
||||||
info_response = get('https://login.yandex.ru/info', headers={
|
info_response = get('https://login.yandex.ru/info', headers={
|
||||||
'Authorization': f'OAuth {access_token}'
|
'Authorization': f'OAuth {access_token}'
|
||||||
})
|
})
|
||||||
if info_response.status_code != 200:
|
if info_response.status_code != 200:
|
||||||
self.logger.warning("Cant access, json: %s", response.json())
|
raise Exception("Cant access, json: " + str(response.json()))
|
||||||
return '/welcome'
|
return '/welcome'
|
||||||
data = info_response.json()
|
data = info_response.json()
|
||||||
yandex_id = data['id']
|
yandex_id = data['id']
|
||||||
|
Loading…
Reference in New Issue
Block a user