Note how the headers parameter is set by calling the headers() method on the client class. This method regenerates the JWT every time, so that the time-sensitive components are appropriate for the request. In v3.0.0, the new _add_jwt_to_request_headers method is used. This uses a cached JWT, which appears to be set globally on the client on initialisation. Consequently, when the token expires users must create a new client instance. Original issue reported (see JIRA ticket):
To reproduce:
client = Client(application_id=nx_application_id, private_key=nx_private_key)
voice = Voice(client)
resp = voice.get_calls()
or
resp = client.voice.get_calls()
Will work at the beginning, but after a few minutes (60s????) if you run .get_calls you will get error:
vonage.errors.AuthenticationError: Check you're using a valid authentication method for the API you want to use
In v2.8.0, requests requiring JWT authentication would call the
parse
method like so:Note how the
headers
parameter is set by calling theheaders()
method on the client class. This method regenerates the JWT every time, so that the time-sensitive components are appropriate for the request. In v3.0.0, the new_add_jwt_to_request_headers
method is used. This uses a cached JWT, which appears to be set globally on the client on initialisation. Consequently, when the token expires users must create a new client instance. Original issue reported (see JIRA ticket):To reproduce: client = Client(application_id=nx_application_id, private_key=nx_private_key) voice = Voice(client)
resp = voice.get_calls() or resp = client.voice.get_calls()
Will work at the beginning, but after a few minutes (60s????) if you run .get_calls you will get error:
vonage.errors.AuthenticationError: Check you're using a valid authentication method for the API you want to use
refresh jwt manually:
or
both will work again for a short time.