def __requestSocialToken(self): dict = {"identity_provider_url": __ACCOUNT_IDENTITY_PROVIDER_URL__, "access_token": self.session_token} token_request = self.session.post(__ACCOUNT_SOCIAL_AUTHENTICATE__, data=json.dumps(dict)) if token_request.ok: self.session.headers["Authorization"] = "JWT " + token_request.json()["token"] # Save the token try: session_token_store = Store("app://tokens/social/{username}".format(username=self.username)) session_token_store.clear() session_token_store.append(token_request.json()["token"]) except: pass
def __requestSessionToken(self): login_dict = {"Login": self.username, "Password": self.password} r = self.session.post(__ACCOUNT_CREATE_SESSION__, headers=self.auth_headers, data=json.dumps(login_dict)) if r.ok and 'Fault' not in r.json(): if r.json()["data"]["subscriptionStatus"] != "active": raise ValueError('Subscription is not active.') self.session_token = r.json()["data"]["subscriptionToken"] # Save the token try: session_token_store = Store("app://tokens/session/{username}".format(username=self.username)) session_token_store.clear() session_token_store.append(self.session_token) except: pass else: raise ValueError('Account Authentication failed.')