question on expiry time in oauth2?

oauth-expire-issue.pngI set the expiry time of 10 seconds in my oauth token generation policy. But in the response i do see expire time of 9 seconds.is it because of latency? @Dino-at-Google @Anil Sagar @ Google @Siddharth Barahalikar.oauth-issue.png

0 2 368
2 REPLIES 2

Yes it is latency, but not latency related to sending the token response to the client. Instead, it's network latency and I/O associated to storing the token within the Apigee system.

The content of the response payload is set by the OAuth policy implicitly. The policy creates a new token and writes it to a persistent store, then creates the response. The time between writing to the store (and waiting for that write to complete) and creating the response payload is the latency we're talking about. It's usually microseconds. But if the token lifetime is 10.00000 seconds, and it takes 450 microseconds (0.45 milliseconds) to write the token to the store and get the confirmation, then the remaining token lifetime is 9.9995 seconds. The policy rounds down to a whole number of seconds, giving you 9.

If you configure a token to last for 30 minutes, the expiry is almost always shown as 1799 in the response payload. In your case you configured it to be 10 seconds, and you saw 9. 10 seconds would be more "accurate" but, because we are dealing with expiration, it would be incorrect. In other words if the client tried to use the token in 10 seconds, it would be invalid. Whereas if the client tried to use the token in 9 seconds, it would be treated as valid.

Hi Arun,

Hopefully my comment is not too much off topic, but… Are you aware that Apigee has limits on expiry times: see https://docs.apigee.com/api-platform/reference/limits that state that the expiry of access tokens should be longer than 180 seconds, and are planned to be enforced in future.

We are having issues with cache expiry time, where we feel that 180 seconds is way too long. So just be aware of this and maybe have a look and add a response to my question about the 180 sec expiry limit yesterday.

So I am also wondering about the view that Apigee support has on this.

Regards, Bas.