Using Auth0.WinformsWPF, how do I obtain and use a refresh token?

283 views Asked by At

Thanks for looking.

Background

I am developing an Outlook add-in that requires our users to obtain a token so that they may interact with our API. We use Auth0 for this.

Essentially, when the user attempts to use a feature from our add-in, they are presented with a sign-in dialog that is powered by Auth0's Auth0.WinformsWPF nuget package (if they are not yet authenticated):

enter image description here

Of course, our users do not care to sign in to our API every time the token expires so I need to make use of Auth0's Refresh Token so that if our code attempts to call the API but the token is expired, I can refresh it without asking the user to log back in.

Problem

I do not see an obvious way to obtain or make use of the refresh token using Auth0.WinformsWPF package. Launching the above dialog to obtain a token is pretty simple however:

auth0.LoginAsync(wrapper, "","openid name email email_verified picture given_name family_name sso").ContinueWith(t => {

//Callback logic after successful authentication.

},
 TaskScheduler.FromCurrentSynchronizationContext())

Question

Preferably using Auth0.WinformsWPF, how do I obtain and use a refresh token? I would very much appreciate some example code.

1

There are 1 answers

1
Eugenio Pace On

You need to add the offline_access parameter to scope. That will instruct Auth0 to return a refresh_token