【发布时间】:2015-06-23 00:22:44
【问题描述】:
我正在尝试在我的 Asp.net 应用程序 (C#) 中使用 OAuth 2。问题是我需要使用共享的谷歌帐户。为此,我的计划是使用令牌、到期日期和刷新令牌为身份验证提供种子,然后在需要身份验证时检查到期日期并使用刷新令牌。
我用于身份验证的示例如下所示:
UserCredential credential;
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
{
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
// This OAuth 2.0 access scope allows an application to upload files to the
// authenticated user's YouTube channel, but doesn't allow other types of access.
new[] { YouTubeService.Scope.YoutubeUpload },
"user",
CancellationToken.None
);
}
而且似乎不包含带有刷新令牌的对象。
如何获取刷新令牌和到期日期?
【问题讨论】:
标签: c# asp.net oauth google-api youtube-api