multiple retries for fetching token
This commit is contained in:
@@ -10,15 +10,22 @@ api_root = root_url + 'api/'
|
|||||||
token_url = root_url + 'oauth/token/'
|
token_url = root_url + 'oauth/token/'
|
||||||
client_id = 'neofarm'
|
client_id = 'neofarm'
|
||||||
client_secret = 'Wk&%g#d8lYFUDrU7k7k%5ZS$V@hHauBq'
|
client_secret = 'Wk&%g#d8lYFUDrU7k7k%5ZS$V@hHauBq'
|
||||||
|
fetch_retries = 10;
|
||||||
|
|
||||||
def init_api():
|
def init_api():
|
||||||
client = BackendApplicationClient(client_id=client_id)
|
client = BackendApplicationClient(client_id=client_id)
|
||||||
oauth_session = OAuth2Session(client=client)
|
oauth_session = OAuth2Session(client=client)
|
||||||
|
for i in range(fetch_retries):
|
||||||
|
try:
|
||||||
token = oauth_session.fetch_token(
|
token = oauth_session.fetch_token(
|
||||||
token_url = token_url,
|
token_url = token_url,
|
||||||
client_id = client_id,
|
client_id = client_id,
|
||||||
client_secret = client_secret
|
client_secret = client_secret
|
||||||
)
|
)
|
||||||
|
break
|
||||||
|
except ConnectionError:
|
||||||
|
print("Fehler bei Verbindung mit Server (wahrscheinlich DuckDns) probiere erneut...")
|
||||||
|
|
||||||
oauth = OAuth2(client_id=client_id, client=client, token=token)
|
oauth = OAuth2(client_id=client_id, client=client, token=token)
|
||||||
|
|
||||||
api = jsonapi_requests.orm.OrmApi.config({
|
api = jsonapi_requests.orm.OrmApi.config({
|
||||||
|
|||||||
Reference in New Issue
Block a user