python-social-auth/social-core

Extra data field 'expires' is required to refresh auth token

IsaacTru opened this issue · 1 comments

Expected behaviour

The documentation should state that in order for the access token and refresh token to be refreshed automatically when using .get_access_token(load_strategy()) to automatically handle the process, the extra_data field on the backend should have the key expires, which is the time in seconds that the token expires in from when it was issued.

Actual behaviour

Using a custom backend implementation for Onshape OAuth, their implementation returns the field expires_in instead of expires. Due to this, my access token was never being refreshed when I used the method above. I manually mapped the parameters using the EXTRA_DATA field in the custom backend via EXTRA_DATA = [('expires_in', 'expires')].

What are the steps to reproduce this issue?

To reproduce, you must be able to use the Onshape Oauth system, or have another provider that returns the same value.

Any logs, error output, etc?

N.A.

Any other comments?

Since this doesn't seem to be a common situation, this is mostly just an issue to document the behavior in case anyone else runs into a similar issue, and can find a result on Google to solve the problem. However, I may also like to submit a PR for the documentation to add this note, as it is in my opinion, a critical assumption of the OAuth flow to get this app to work properly in Django.

Adding to this in case it helps anyone else, the microsoft graph oauth system also returns 'expires_in' instead of 'expires'. We had to make sure to copy it over to the expires key ourselves.