1

I'm using the Dailymotion API which uses Oauth2, their client tokens expire in 36000 seconds (10 hours), so I thought of creating new tokens for every call with the refresh token URL provided. Also, I didn't find any warnings in the documentation preventing me from doing this, is this a bad practice?

2 Answers2

2

Yes, it is a bad practice, even though it's feasible. Authorization Servers might impose rate limiting on your client so that at some point you won't be able to refresh the token.

The access token must have expiration time for security reasons. If anyone manages to get hold of that token they will be able to use it only for the specified time. Good practice is to have as short expiration times as possible - e.g. 5 or 15 minutes. The 10 hours used by Dailymotion is a bit much, in my opinion, but it's their decision.

Refresh tokens should be kept securely by your client and you usually need a client secret to make a refresh request. This means that generally it's much harder for an attacker to get hold of a refresh token (or use it once they manage to steal it).

Michal Trojanowski
  • 10,641
  • 2
  • 22
  • 41
2

creating a new token on every requests is not the best way to proceed.

During your request, you can check (ex: with a "try") if your access token has expired then request new one with your given refresh token only if necessary.

If you are using a language like PHP, Python, Javascript, ... you can save much time using the available SDKs that already implement these mechanisms.

cf. https://developer.dailymotion.com/tools/sdks/

dailymotion
  • 1,546
  • 1
  • 9
  • 11