mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-19 15:36:02 +00:00
Add support for token login (for bots)
This commit is contained in:
parent
e64787a415
commit
7f340f88ad
@ -464,6 +464,24 @@ class Client:
|
||||
passing status code.
|
||||
"""
|
||||
|
||||
if email == "token":
|
||||
log.info('logging in using static token')
|
||||
self.token = password
|
||||
self.headers['authorization'] = 'Bot {}'.format(self.token)
|
||||
resp = yield from self.session.get(endpoints.ME, headers=self.headers)
|
||||
log.debug(request_logging_format.format(method='GET', response=resp))
|
||||
|
||||
if resp.status != 200:
|
||||
yield from resp.release()
|
||||
if resp.status == 400:
|
||||
raise LoginFailure('Improper token has been passed.')
|
||||
else:
|
||||
raise HTTPException(resp, None)
|
||||
|
||||
log.info('token auth returned status code {}'.format(resp.status))
|
||||
self._is_logged_in.set()
|
||||
return
|
||||
|
||||
# attempt to read the token from cache
|
||||
if self.cache_auth:
|
||||
yield from self._login_via_cache(email, password)
|
||||
|
Loading…
x
Reference in New Issue
Block a user