Code : Tout sélectionner
nokia_user = NokiaUserCode : Tout sélectionner
nokia_user = NokiaUser()Code : Tout sélectionner
nokia_user = NokiaUserCode : Tout sélectionner
nokia_user = NokiaUser()"""
While python-nokia takes care of automatically refreshing the OAuth2 token
so you can seamlessly continue making API calls, it is important that you
persist the updated tokens somewhere associated with the user, such as a
database table. That way when your application restarts it will have the
updated tokens to start with. Pass a ``refresh_cb`` function to the API
constructor and we will call it with the updated token when it gets
refreshed. The token contains ``access_token``, ``refresh_token``,
``token_type`` and ``expires_in``. We recommend making the refresh callback
a method on your user database model class, so you can easily save the
updates to the user record, like so:
class NokiaUser(dbModel):
def refresh_cb(self, token):
self.access_token = token['access_token']
self.refresh_token = token['refresh_token']
self.token_type = token['token_type']
self.expires_in = token['expires_in']
self.save()
Then when you create the api for your user, just pass the callback:
user = ...
creds = ...
api = NokiaApi(creds, refresh_cb=user.refresh_cb)
Now the updated token will be automatically saved to the DB for later use.
"""
Je pense que c'est ça effectivement. Je viens de faire le test, j'attends que mon token expire pour confirmerpapoo a écrit : 05 nov. 2018, 22:10 pour appeler la class NokiaUser, en lieu et place dene faudrait il pasCode : Tout sélectionner
nokia_user = NokiaUser?Code : Tout sélectionner
nokia_user = NokiaUser()