python-social-auth / social-core

Python Social Auth - Core
BSD 3-Clause "New" or "Revised" License
850 stars 544 forks source link

Fix access token expiration and refresh token handling in GitHub backend #932

Closed gmargaritis closed 2 months ago

gmargaritis commented 2 months ago

The access_token expiration value is not stored correctly by the GitHub backend, leading to the refresh token functionality not being triggered.

This issue occurs because the GitHub backend uses a different key (expires^1) than the one used by GitHub (and by extension, the OAuth2 RFC^2), which is expires_in^3. This misconfiguration results in the expiration value always being None^4, preventing the refresh functionality from being called^5.

In order for the refresh functionality, that is already present in the UserMixin^6 and BaseOAuth2 ^7, to be utilized by the GitHub backend, we have to also include the refresh_token key in the extra_data ^1. This ensures that we always store it and use it as outlined by GitHub^3.

I’ll open a pull request handling the issue.