Extract username from session
This commit is contained in:
parent
6134945df7
commit
e77e0f9e35
|
@ -201,10 +201,11 @@ class _Network:
|
||||||
self.last_call_time = 0
|
self.last_call_time = 0
|
||||||
self.limit_rate = False
|
self.limit_rate = False
|
||||||
|
|
||||||
# Load session_key from authentication token if provided
|
# Load session_key and username from authentication token if provided
|
||||||
if token and not self.session_key:
|
if token and not self.session_key:
|
||||||
sk_gen = SessionKeyGenerator(self)
|
sk_gen = SessionKeyGenerator(self)
|
||||||
self.session_key = sk_gen.get_web_auth_session_key(url=None, token=token)
|
self.session_key, self.username = \
|
||||||
|
sk_gen.get_web_auth_session_key(url=None, token=token)
|
||||||
|
|
||||||
# Generate a session_key if necessary
|
# Generate a session_key if necessary
|
||||||
if (
|
if (
|
||||||
|
@ -988,7 +989,7 @@ class SessionKeyGenerator:
|
||||||
b. sg = SessionKeyGenerator(network)
|
b. sg = SessionKeyGenerator(network)
|
||||||
c. url = sg.get_web_auth_url()
|
c. url = sg.get_web_auth_url()
|
||||||
d. Ask the user to open the URL and authorize you, and wait for it.
|
d. Ask the user to open the URL and authorize you, and wait for it.
|
||||||
e. session_key = sg.get_web_auth_session_key(url)
|
e. session_key, username = sg.get_web_auth_session_key(url)
|
||||||
2) Username and Password Authentication:
|
2) Username and Password Authentication:
|
||||||
a. network = get_*_network(API_KEY, API_SECRET)
|
a. network = get_*_network(API_KEY, API_SECRET)
|
||||||
b. username = raw_input("Please enter your username: ")
|
b. username = raw_input("Please enter your username: ")
|
||||||
|
@ -1062,7 +1063,9 @@ class SessionKeyGenerator:
|
||||||
|
|
||||||
doc = request.execute()
|
doc = request.execute()
|
||||||
|
|
||||||
return doc.getElementsByTagName("key")[0].firstChild.data
|
session_key = doc.getElementsByTagName("key")[0].firstChild.data
|
||||||
|
username = doc.getElementsByTagName("name")[0].firstChild.data
|
||||||
|
return session_key, username
|
||||||
|
|
||||||
def get_session_key(self, username, password_hash):
|
def get_session_key(self, username, password_hash):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue