C# NativeApplicationClient不受任何支持
在我的Visual Studio Win form项目中使用此代码时C# NativeApplicationClient不受任何支持,c#,.net,google-api,google-oauth,google-api-dotnet-client,C#,.net,Google Api,Google Oauth,Google Api Dotnet Client,在我的Visual Studio Win form项目中使用此代码时 var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description, ClientId, ClientSecret); 我收到一条消息 NativeApplicationClient不再受支持,将在1.7.0-beta版中删除。考虑使用新的GoGoL.Apsi.AuthNuGet包,它支持.NET 4、.NET用于Windows商
var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description, ClientId, ClientSecret);
我收到一条消息
NativeApplicationClient不再受支持,将在1.7.0-beta版中删除。考虑使用新的GoGoL.Apsi.AuthNuGet包,它支持.NET 4、.NET用于Windows商店应用程序、Windows Phone 7.5和8以及便携式类库以及
我正在使用
安装包Google.api.Authentication-pre
如果我添加Google.api.auth而不是Google.api.Authentication,它甚至不会有NativeApplicationClient。但是我找不到任何关于我使用什么来代替NativeApplicationClient的信息。是的,我让它工作了 在项目中安装这些软件包
pm> install-package google.apis -pre
pm> install-package google.apis.drive.v2 -pre
添加这些用法
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
using System.IO;
using Google.Apis.Drive.v2;
using Google.Apis.Util.Store;
using System.Threading;
private void Form1_Load(object sender, EventArgs e)
{
UserCredential credential;
using (var stream = new FileStream("client_secrets.json", FileMode.Open,
FileAccess.Read)) {
GoogleWebAuthorizationBroker.Folder = "Tasks.Auth.Store";
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] { DriveService.Scope.Drive,
DriveService.Scope.DriveFile },
"user",
CancellationToken.None,
new FileDataStore("Drive.Auth.Store")).Result;
}
}
对于谷歌硬盘,我会创建一个硬盘服务。您发送所有针对该服务的呼叫。谷歌分析也是如此
BaseClientService service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Drive API Sample",
});
我在一篇博文中解释了这一切:
如果你告诉我如何给它一个存储的refrshToken并使用它,让我知道我仍在试图告诉它 我可以知道GoogleWebAuthorizationBroker.Folder=“Tasks.Auth.Store”的用途吗?如果删除文件数据存储,GoogleWebAuthorizationBroker.Folder将告诉它在何处存储身份验证。从技术上讲,你不需要两者兼而有之。这里有一个更新的教程,它比本教程更好地解释了这一点