mirror of
https://github.com/no2chem/wideq.git
synced 2025-05-16 07:10: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('Then paste the URL where the browser is redirected:')
|
||||
callback_url = input()
|
||||
access_token, refresh_token = wideq.parse_oauth_callback(callback_url)
|
||||
return wideq.Auth(gateway, access_token, refresh_token)
|
||||
return wideq.Auth.from_url(gateway, callback_url)
|
||||
|
||||
|
||||
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.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):
|
||||
"""Start an API session for the logged-in user. Return the
|
||||
Session object and the user's devices.
|
||||
|
Loading…
x
Reference in New Issue
Block a user