简体   繁体   English

使用Auth0.WinformsWPF,如何获取和使用刷新令牌?

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

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. 我正在开发一个Outlook加载项,它要求我们的用户获取令牌,以便他们可以与我们的API交互。 We use Auth0 for this. 为此 ,我们使用Auth0

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): 本质上,当用户尝试使用外接程序中的功能时,会显示一个登录对话框,该对话框由Auth0的Auth0.WinformsWPF nuget软件包提供支持(如果尚未进行身份验证):

在此处输入图片说明

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. 当然,我们的用户不必在每次令牌过期时都登录到我们的API,因此我需要使用Auth0的刷新令牌,这样,如果我们的代码尝试调用API但令牌已过期,则我可以刷新它而无需要求用户重新登录。

Problem 问题

I do not see an obvious way to obtain or make use of the refresh token using Auth0.WinformsWPF package. 我看不到使用Auth0.WinformsWPF软件包获取或使用刷新令牌的明显方法。 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? 最好使用Auth0.WinformsWPF ,如何获取和使用刷新令牌? I would very much appreciate some example code. 我非常感谢一些示例代码。

You need to add the offline_access parameter to scope . 您需要将offline_access参数添加到scope That will instruct Auth0 to return a refresh_token 这将指示Auth0返回refresh_token

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用刷新令牌通过 Google API (C#) 生成新的身份验证令牌? - How can I use the Refresh Token to generate a new Auth Token using the Google API (C#)? 如何使用刷新令牌为Google SpreadsheetsService获取新的访问令牌 - How do I use a refresh token to get a new access token for Google SpreadsheetsService 如何使用带有身份验证令牌的DataContractJsonSerializer - How to use DataContractJsonSerializer with auth token 如何实现谷歌 API 刷新令牌 - How do I implement Google API refresh token 如何使用 IHttpClientFactory 刷新令牌 - How to Refresh a token using IHttpClientFactory 如何使用刷新令牌续订访问令牌? - How to renew the access token using the refresh token? 如何使用 C# 从 Identity Server 4 中正确获取令牌以在 Postman 中使用? - How to properly obtain the token using C# from Identity Server 4 to use in Postman? 如何获取应用程序的Facebook访问令牌以在公司墙上发布? - How do I obtain a Facebook access token for an app to post on a company wall? 如何为Azure AD创建和使用刷新令牌 - How to create and use a refresh token for Azure AD 如何在IdentityServer 4中使用'refresh_token'? - How to use 'refresh_token' in IdentityServer 4?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM