mirror of
https://github.com/no2chem/wideq.git
synced 2025-05-16 15:20:09 -07:00
Auth.from_url helper
This commit is contained in:
parent
8fc2749a9b
commit
35a78281d6
@ -31,8 +31,7 @@ def authenticate(gateway):
|
|||||||
print(login_url)
|
print(login_url)
|
||||||
print('Then paste the URL where the browser is redirected:')
|
print('Then paste the URL where the browser is redirected:')
|
||||||
callback_url = input()
|
callback_url = input()
|
||||||
access_token, refresh_token = wideq.parse_oauth_callback(callback_url)
|
return wideq.Auth.from_url(gateway, callback_url)
|
||||||
return wideq.Auth(gateway, access_token, refresh_token)
|
|
||||||
|
|
||||||
|
|
||||||
def get_session(state, reauth=False):
|
def get_session(state, reauth=False):
|
||||||
|
8
wideq.py
8
wideq.py
@ -157,6 +157,14 @@ class Auth(object):
|
|||||||
self.access_token = access_token
|
self.access_token = access_token
|
||||||
self.refresh_token = refresh_token
|
self.refresh_token = refresh_token
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_url(cls, gateway, url):
|
||||||
|
"""Create an authentication using an OAuth callback URL.
|
||||||
|
"""
|
||||||
|
|
||||||
|
access_token, refresh_token = parse_oauth_callback(url)
|
||||||
|
return cls(gateway, access_token, refresh_token)
|
||||||
|
|
||||||
def start_session(self):
|
def start_session(self):
|
||||||
"""Start an API session for the logged-in user. Return the
|
"""Start an API session for the logged-in user. Return the
|
||||||
Session object and the user's devices.
|
Session object and the user's devices.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user