Skip to content

Commit

Permalink
adding legacy retrieveToken method for backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
pitchmuc committed Jan 19, 2021
1 parent 1281b57 commit 832ada2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions aanalytics2/aanalytics2.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,20 @@ def getCompanyId(infos: str = 'all'):
except:
print("exception when trying to get companies with parameter != 'all'")
return None

def retrieveToken(verbose: bool = False, save: bool = False, **kwargs)->str:
"""
LEGACY retrieve token directly following the importConfigFile or Configure method.
"""
token_with_expiry = token_provider.get_token_and_expiry_for_config(config.config_object,**kwargs)
token = token_with_expiry['token']
config.config_object['token'] = token
config.config_object['date_limit'] = time.time() + token_with_expiry['expiry'] / 1000 - 500
if verbose:
print(f"token valid till : {time.ctime(time.time() + token_with_expiry['expiry'] / 1000)}")
config.header.update({'Authorization': f'Bearer {token}'})
return token



class Login:
Expand Down

0 comments on commit 832ada2

Please sign in to comment.