Authenticate with the API on server side | Community
Skip to main content
Answered

Authenticate with the API on server side

  • February 13, 2023
  • 4 replies
  • 155 views

Benjamin Clanet

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

Best answer by andrew_videoask

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

View original

4 replies

Grace
Community Team
Forum|alt.badge.img+5
  • Community Advocate
  • 2687 replies
  • February 13, 2023

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 😊


Benjamin Clanet

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?


andrew_videoask
Typeform
Forum|alt.badge.img+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


Benjamin Clanet

Excellent, thank you team !


Reply