I have a simple app that provides a random quote on a website, taken from a Google spreadsheet using the Python library, gspread. There is a Javascript reload button that allows the user to refresh the page and get a new random quote. I am using OAuth2 credentials to authorize the call to my spreadsheet. Here's a snippet:
json_file = open(os.path.join(current.request.folder, 'private', 'quote_generator.json'))
json_key = json.load(json_file)
scope = ['https://spreadsheets.google.com/feeds']
credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope)
gc = gspread.authorize(credentials)
Refreshing the page generates a new quote for the first few times but then errors. Looking at my error log, all of the errors are from "Refreshing access_token", which I think is an OAuth problem. How can I fix this so that users can refresh the quotes as many times as they like?