2

我对 MVC 很陌生,真的很喜欢它只是习惯了一切。我想实现的一件事是谷歌登录(完成),能够使用响应作为访问日历和联系人 API 的一种方式。

我正在尝试找到可以使用 AuthConfi.cs 文件中的 RegisterGoogleClient 方法提供 API 密钥的内容。

我已经向谷歌注册了一个应用程序,并且拥有请求日历和联系人权限的密钥。只是似乎无法找到在 RegisterGoogleClien 中包含此密钥的缺失链接。

理想情况下,我将能够获取传入的密钥,用户将看到对其他项目的权限请求,然后提供的 OAuth 密钥将可用于 GData NuGet 包。

提前致谢!

ps-我猜我需要使用允许传入字典但也找不到任何文档的重载,可能只是找错了地方,但我已经找了几天了。

4

1 回答 1

0

At the moment I have the same problem as yours. I can authenticate the user (log in with google), but I cannot retrieve the user contacts. The access_token that is returned from gmail is not valid for accessing the user contacts. I need to authenticate the user, and in the same time to send my client_id and secret of the application that is registered at the google console. Then with that access_token probably I will be able to retrieve the user contacts.

RequestSettings r = new RequestSettings(app, access_token); // how to get the access_token ???
//if i have new RequestSettings(app, user_email, password); it works
ContactsRequest cRequest = new ContactsRequest(r);

Feed<Contact> feedContacts = cRequest.GetContacts(user.email);

List<string> list = new List<string>();
foreach (Contact gmailAddresses in feedContacts.Entries)
{
    // Looping to read email addresses
    foreach (EMail emailId in gmailAddresses.Emails)
    {
       list.Add(emailId.Address);
    }
}
于 2013-11-23T10:12:03.697 回答