Reputation: 405
I'm working on a web app that displays a list of youtube videos for the user to watch, and it's working fine, but when I leave the app alone for a period of time, 45 minutes or so, when I try to make another API request I get a 403 Error: "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup." If I refresh the page it works fine again and it doesn't matter how many individual requests I've made, it simply seems to be a timeout. I can't find any specifics on how long this timeout is, how to prevent or extend it, or anything else. Does anyone know?
Also, if I manually call the gapi.client.setApiKey() and gapi.client.load() again from the javascript console it works just fine, I figure I can just set a 30 minute timeout or whatever to refresh this but that seems kind of annoying.
Upvotes: 0
Views: 1216
Reputation: 36541
Your oauth access token is timing out. The accessToken only lasts 60 minutes, so when you don't refresh the page (and get a new accessToken presumably), you are attempting to use an expired accessToken which results in that error message. You could look into using refresh tokens, which allows you to request a new accessToken once yours has expired. This page explains how to setup refresh tokens
Upvotes: 1