Skip to main content

 

Documentation & User Guides | FotoWare

Good Practice for Requesting Access Tokens

Access tokens have limited lifetime. However, several strategies that can be employed to make sure you always have a valid token for your integration to use. The strategy used depends on the type of integration you're making.

Example:

You're making an app that performs a search via the API every hour and then executes some automatic metadata updates.

Approach 1

You can request a new access token every time the app runs and then run all subsequent requests using this access token. The next time a workflow is run, you request a new access token. This is a simple strategy that will work great for workflows that run intermittently, and about 90% of all "background apps" will work fine with this approach.

Approach 2

A more thorough approach is to check the response of each request, and if it fails with a 401, you request a new access token and re-run the request. This requires some more implementation work but is bullet-proof and will ensure you always have a valid access token.

Approach 3

Make your app proactively request an access token every 30 minutes and use this for all requests in the next half hour.