Google Contact api v3 身份验证
我尝试使用新的谷歌联系人 API。 我的任务很简单 - 从静态(我的个人)域帐户检索联系人。 我在 API 控制台注册我的应用程序并获取 ClientId、ClientSecret 所以我尝试通过 .net(google SDK) 验证我的应用程序
RequestSettings settings = new RequestSettings(appName,login,password);
ContactsRequest cr = new ContactsRequest(settings);
Feed<Contact> contacts = cr.GetContacts();
foreach (Contact entry in contacts.Entries)
{
....
}
此代码运行良好,但 Google 表示我们应该在生产场景中使用 OAuth2 身份验证。 我在 RequestSettings
尝试不同的参数,但在其他变体中我得到 401(访问被拒绝)。 所以我的问题是,在安装的 desctop 应用程序中通过 google API v3 进行身份验证而不使用其他帐户凭据的正确方法是什么。
I try use new google contacts API.
My task is simple - retrieve contacts from static(my personal) domain account.
I register my application at APIs Console and get ClientId,ClientSecret
So I try authenticate my application through .net(google SDK)
RequestSettings settings = new RequestSettings(appName,login,password);
ContactsRequest cr = new ContactsRequest(settings);
Feed<Contact> contacts = cr.GetContacts();
foreach (Contact entry in contacts.Entries)
{
....
}
This code works well, but Google said that we should use OAuth2 authentication at production scenario.
I try different parameters at RequestSettings
but at other variant I get 401(access denied).
So my question what's the right way to auth through google API v3 at installed desctop application without using other accounts credentials.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在开始工作之前,您应该获得身份验证令牌。为此,您应该创建用户应该打开并允许访问您的应用程序的链接。
您应该使用稍后获得的代码请求令牌。
https://developers.google.com/accounts/docs/OAuth2Login 中介绍了此机制
像这样的东西:
ResponseCode 这是用户从“访问授予页面”重定向后应该捕获的代码
但我猜这个方法是 api 2...也许我错了,谁知道呢
Before start to work you should get auth token. For do this you should create link whitch user should open and grand access to your app.
Than you should request for token with the code witch you get later.
This mechanism described at https://developers.google.com/accounts/docs/OAuth2Login
something like this:
ResponseCode it's a code what you should catch after user redirect from "access granting page"
But this method is api 2 i guess... Maybe I'm wrong, who know