fusionauth-typescript-client icon indicating copy to clipboard operation
fusionauth-typescript-client copied to clipboard

SDK method to return current access token or refresh it if expired

Open quarryman opened this issue 3 years ago • 4 comments

Hi team.

I am trying to mimic SDK behavior available in Auth0 js client or AWS Cognito js client (Amplify), which both provide SDK method to retrieve current token or automatically refresh it silently and return refreshed one, so that one dont have to handle expiration manually.

Auth0 will always return current(refreshed if needed) token with Auth0.getTokenSilently()

Cognito provides similar approach with const session = await Auth.currentSession().getAccessToken();

Again, it will refresh token if expired under the hood

Is there smth similar in FusionAuth js client that will abstract getting fresh token flow into single function?

quarryman avatar Apr 04 '22 19:04 quarryman

@quarryman FusionAuth's client libs are pretty close to the metal and don't currently offer that functionality.

I'd be happy to review a PR.

mooreds avatar Apr 04 '22 19:04 mooreds

thanx for being responsive @mooreds At this stage we are evaluating FusionAuth, I would consider PR if we find match with the library. Thanx!

quarryman avatar Apr 05 '22 12:04 quarryman

No worries, @quarryman !

We can leave this open and see if other community members chime in and want it.

mooreds avatar Apr 05 '22 12:04 mooreds

We can leave this open and see if other community members chime in and want it.

We definitely want this (along with PKCE handling). I've opened #1674 since this is not specific to the TS client.

glen-84 avatar Apr 11 '22 13:04 glen-84