def get_auth_token(self):
"""
Retrieves an auth_session_token using DEP server token data prepared as an
OAuth1Session() instance earlier on.
"""
# Retrieve session auth token
get_session = self.dep_prep('session', 'get', authsession=self.oauth)
response = self.oauth.send(get_session)
# Extract the auth session token from the JSON reply
token = response.json()['auth_session_token']
# The token happens to contain the UNIX timestamp of when it was generated
# so we save it for later reference.
timestamp = token[:10]
# Roll a human-readable timestamp as well.
ts_readable = datetime.datetime.fromtimestamp(
int(timestamp)).strftime(
'%Y-%m-%d %H:%M:%S')
print "Token generated at %s" % ts_readable
return token, timestamp
评论列表
文章目录