如果我创建一个像这样的新驱动器服务:
public void CreateDriveService()
{
string SERVICE_ACCOUNT_EMAIL = "xxxxxxx-xxxxxxxxxxxxxx@developer.gserviceaccount.com";
string SERVICE_ACCOUNT_PKCS12_FILE_PATH = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ExecutablePath), @"xxxxxxxxxxxxxxx-privatekey.p12");
X509Certificate2 certificate = new X509Certificate2(SERVICE_ACCOUNT_PKCS12_FILE_PATH, "notasecret",
X509KeyStorageFlags.Exportable);
var provider = new AssertionFlowClient(GoogleAuthenticationServer.Description, certificate)
{
ServiceAccountId = SERVICE_ACCOUNT_EMAIL,
Scope = DriveService.Scopes.Drive.GetStringValue(),
};
var auth = new OAuth2Authenticator<AssertionFlowClient>(provider, AssertionFlowClient.GetState);
auth.LoadAccessToken();
_service = new DriveService(auth);
}
我得到了一个新的驱动服务,但是如果我看到访问令牌它有29.05.2014 12:25:11作为AccessTokenExpirationUtc但现在它是29.05.2014 13:25:11! 怎么可能??? 我已经更改了谷歌驱动器上的时区但仍然存在同样的问题....
提前致谢
答案 0 :(得分:0)
当比较任何两次时,它们必须具有相同的时区。访问令牌到期时间以UTC格式给出。如果您想了解未来的距离,则应将其与系统当前的UTC时间进行比较。这个问题How to make date.getTime() returns UTC time?给出了一个如何做到这一点的例子