0
我正在uwp上編寫應用程序。我必須從login.live.com獲取令牌,但我不知道如何獲得此令牌的到期時間。我有該代碼:cuth中的OAuth2令牌過期時間#
var tokenProvider = await WebAuthenticationCoreManager.FindAccountProviderAsync(_webProviderId);
var tokenRequest = new WebTokenRequest(tokenProvider, Scopes.ToString());
var tokenRequestResult = await WebAuthenticationCoreManager.RequestTokenAsync(tokenRequest);
if (tokenRequestResult.ResponseStatus == WebTokenRequestStatus.Success)
{
var tokenResponse = tokenRequestResult.ResponseData.First();
Token.SetToken(tokenResponse.Token, 3600); // add server expiration time
Scopes.Updated = true;
}
else { throw new Exception("Token provider error"); }
除了使用WebAuthenticationCoreManager進行身份驗證之外,您是否需要過期時間?它應該自動處理刷新令牌。 – nimatra
@nimatra這意味着字符串中的標記沒有「過期時間」? –
對不起,遲到的迴應,它確實但WebAuthenticationCoreManager正在照顧刷新它。 – nimatra