go icon indicating copy to clipboard operation
go copied to clipboard

Add matrix 1.3 api feature to refresh access token

Open dalees opened this issue 1 year ago • 1 comments

  • Refresh tokens are returned by the Matrix homeserver when ReqLogin.RefreshToken is set.
  • Add new functions to client for Refresh() which uses a previously stored refresh token to update the existing access token once it expires.
  • Implements a fudge factor on the expiry duration so we refresh well before the access token expires.

dalees avatar Oct 16 '24 22:10 dalees

Happy for suggestions of changes to the interface and naming of Refresh and refreshInner functions - it made sense to me to provide some utility that could be called frequently without knowledge of the refresh time internals.

dalees avatar Oct 16 '24 22:10 dalees

Hi @tulir - do you have any feedback on this PR?

This affects our use of the library when using a server that has implemented token expiry, and helps with the issue (though it still requires regular messages to be sent, otherwise the refresh token expires too!)

dalees avatar Mar 12 '25 00:03 dalees

Probably won't bother with this since refresh tokens aren't required and the entire auth system is about to be replaced. I can add the refresh token to the login response though to ensure it can be implemented outside the library (it was already in RespRegister, not sure why it was missed for login)

tulir avatar Mar 12 '25 10:03 tulir