Answered

Authenticate with the API on server side

  • 13 February 2023
  • 4 replies
  • 112 views

Userlevel 1

Hi team,

I am currently integrating the video ask API in my backend to generate forms programmatically (among other things).

In order to get an access_token, I need to manually get an authorization code from my browser, then call https://auth.videoask.com/oauth/token with the code + scope=offline_access to get a refresh token.

So far so good… except that refresh tokens expires after 30 days.

This mean that I would need to remind myself to manually get a new refresh token every ~25 days or so to make sure my backend does not break.

Am I missing something? Is there a solution to automatize it all?

 

Thank you,

Ben

icon

Best answer by andrew_videoask 13 February 2023, 17:29

View original

4 replies

Userlevel 7
Badge +5

Hey @Benjamin Clanet I think you’ll find the answer to your question over here:

 

but let us know if you still need help with the refresh token 😊

Userlevel 1

Hi @Grace, thank you for your quick response !

I’m glad to learn that refresh_token never expires.

I am confused though… as per my screenshot, it says “Generated refresh tokens will last 30 days”, what does it mean in that case?

Userlevel 7
Badge +5

Hi @Benjamin Clanet, you can disregard that interface text. It should say that access tokens expire after 24 hours.

Thankfully, the refresh token never expires! So basically you can generate an access token, cache it for 24 hours, then automatically generate a new access token (using your refresh token) so it lasts another 24 hours. Rinse and repeat!

Here’s an example implementation that uses Python and Redis: https://github.com/andrewdemeter/videoask/blob/main/regenerate-access-token.py

Userlevel 1

Excellent, thank you team !

Reply