本文介绍了[UWP]如何刷新通过OnlineIdAuthenticator获得的MSA令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用OnlineIdAuthenticator来获取MSA令牌,这很好用。  但是,如何在一小时左右过期后刷新令牌?

I use the OnlineIdAuthenticator to get a MSA token and this works fine.  However how do I refresh the token as it expires after an hour or so?

我在这里查看了OneNote示例:

I took a look at the OneNote sample here:

https://github.com/OneNoteDev/OneNoteAPISampleWinUniversal

https://github.com/OneNoteDev/OneNoteAPISampleWinUniversal

在OneNoteServiceSamplesWinUniversal.Shared / OneNoteApi / LiveIdAuth.cs中查看AttemptAccessTokenRequest():

Looking at AttemptAccessTokenRequest() within OneNoteServiceSamplesWinUniversal.Shared/OneNoteApi/LiveIdAuth.cs:

在初始刷新时(硬编码59分钟!)_refreshToken为null,导致send返回BadRequest(我已使用我的应用程序的客户端ID更新了示例)。

On the initial refresh (hardcoded for 59 minutes!) the _refreshToken is null which causes the send to return a BadRequest (I have updated the sample with my app's client id).

所以我认为这不正确所以我应该再次发布OnlineIdAuthenticator :: AuthenticateUserAsync()吗?

So I assume that this isn't correct so should I just issue OnlineIdAuthenticator::AuthenticateUserAsync() again?

感谢您的帮助,非常感谢

Thanks for the help, much appreciated

推荐答案

我测试了这个样本。我将"AccessTokenApproxExpiresInMinutes"更改为1分钟,1分钟后,该应用程序将让我重新登录我的MS帐户。我没有"BadRequest"。我在代码示例中使用了默认客户端ID。

I have tested this sample. I changed the "AccessTokenApproxExpiresInMinutes" to 1 min, and after 1 min, the app would let me re-login my MS account. I have not got "BadRequest". I used the default client id in code sample.

最好的问候,

Xavier Eoro

Xavier Eoro


这篇关于[UWP]如何刷新通过OnlineIdAuthenticator获得的MSA令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 01:31