FusionAuth / fusionauth-typescript-client

A TypeScript client for FusionAuth
https://fusionauth.io
Apache License 2.0
63 stars 27 forks source link

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

Open quarryman opened 2 years ago

quarryman commented 2 years ago

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?

mooreds commented 2 years ago

@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.

quarryman commented 2 years ago

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

mooreds commented 2 years ago

No worries, @quarryman !

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

glen-84 commented 2 years ago

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.