Skip to content

Instantly share code, notes, and snippets.

View franfabrizio's full-sized avatar

Fran Fabrizio franfabrizio

  • Minnesota Population Center
  • Minneapolis, MN
View GitHub Profile
@franfabrizio
franfabrizio / auto-refresh-mendeley-token.py
Last active November 8, 2023 16:06
Python example using refresh token to update access token for Mendeley API using the Mendeley Python SDK
from mendeley import Mendeley
from mendeley.exception import MendeleyException
from mendeley.session import MendeleySession
# extending the MendeleySession class to do auto-token-refresh on
# token expiration. Mendeley access tokens expire after 1 hour.
class AutoRefreshMendeleySession(MendeleySession):
def __init__(self, mendeley, token, refresh_token):
super(AutoRefreshMendeleySession, self).__init__(mendeley, token)
# silly name to avoid namespace collision with oauth refresh_token() method