不支持NativeApplicationClient任何 [英] NativeApplicationClient is not supported any
问题描述
在使用此代码在我的Visual Stuidio赢形式的项目。
When using this code In my Visual Stuidio Win form project.
var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description, ClientId, ClientSecret);
我得到一个消息
I am getting a message
NativeApplicationClient不支持任何更多和它要在1.7.0-β被除去。请考虑使用支持.NET 4的新Google.Apis.Auth的NuGet包,.NET的Windows Store应用程序的Windows Phone 7.5和8便携式类库以及
NativeApplicationClient is not supported any more and it's going to be removed in 1.7.0-beta. Consider using the new Google.Apis.Auth NuGet package which supports .NET 4, .NET for Windows Store apps, Windows Phone 7.5 and 8 and Portable Class Libraries as well
我使用
安装包Google.Apis.Authentication -pre
install-package Google.Apis.Authentication -pre
如果我添加Google.apis.auth而不是Google.Apis.Authentication它不apeare甚至有NativeApplicationClient。但我不能找到什么,我要suposed使用NativeApplicationClient的insted的任何信息。
If i add Google.apis.auth instead of Google.Apis.Authentication it doesnt apeare to even have NativeApplicationClient. But I cant find any information on what I'm suposed to be using insted of NativeApplicationClient.
推荐答案
是的,我得到它的工作。
Yes i got it working.
在项目中安装这些软件包
Install these packages in your project
pm> install-package google.apis -pre
pm> install-package google.apis.drive.v2 -pre
添加这些usings
Add these usings
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;
}
}
}
对于谷歌驱动器,我会再创建一个驱动器服务。您发送对服务的所有呼叫。适用于谷歌分析是一样的。
For google drive i would then create a drive service. You send all the calls against the service. Works the same for google analytics.
BaseClientService service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Drive API Sample",
});
我expain这一切在博客:的 http://daimto.com/google-oauth2-csharp/
如果您figuer如何给它一个存储refrshToken和使用,让我知道我仍然试图figuer了这一点。
If you figuer out how to feed it a stored refrshToken and use that let me know i'm still trying to figuer that out.
这篇关于不支持NativeApplicationClient任何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!