oAuth & refreshToken

With the MS and Google UD plugins, is there any mechanism to obtain a new token using the refresh token? (or has someone done this already?)
I’m building site that relies on interacting with MS Graph api. Problem is that the cf session renews as you interact with it but the oAuth token only lasts for an hour. I could add some code into onrequest to test the token and then log you out of farcry but it would be more convenient to just obtain a new token using the refreshtoken using some function in the UD plugin.

Cheers
Phil

It’s not currently a feature of the plugin as the only time we look at the user info via the API is during the login, but if it’s going to make the plugin more useful then we’d happily accept a pull request any time :slight_smile:

On when to do the token refresh; rather than checking onRequest and refreshing the token even if it isn’t going to be used in the request, could you perhaps check for the token expiry just before an API call is made and refresh it then? Without reading too much into the docs / existing code base, I think I’d want the token refresh to happen when we know it’s going to be used rather than refreshing it on an arbitrary request when it might not be used. Do you think that would be feasible?

Yep, having a function to run before an API call makes sense. Then you can add it anywhere you want, onrequest or whenever needed, depending on your apps needs. I’ll do a pull won’t I have something working.

I’ve created a pull request…

2 Likes

Thanks Phil! I’ll try to review tomorrow and merge the PR, thanks very much :slight_smile:

1 Like