I'm trying to access gmail contacts in asp.net web application.
Still I'm able to get access_token from google, but when I send this acccess_token to google contact api, its giving me error.
Below is the url where I redirect from my application and user authenticates by giving his email and password.
https://accounts.google.com/o/oauth2/auth?scope=https://www.google.com/m8/feeds&redirect_uri=http://localhost:3223/WebSite1/Default.aspx&response_type=token&client_id=881595232473.apps.googleusercontent.com
After this user came back to my web application with access token.
Here I've used two diferent methods to get all contacts:
Method 1 - Web Request:
HttpWebRequest request1 = (HttpWebRequest)WebRequest.Create(url1);
HttpWebResponse response1 = (HttpWebResponse)request1.GetResponse();
System.IO.Stream ReceiveStream1 = response1.GetResponseStream();
StreamReader readStream1 = new StreamReader(ReceiveStream1);
string result = readStream1.ReadToEnd();
Its working fine and gives me result in XML. But problem is that its giving only first 25 contacs while i've total 246 contacts.
Method 2 - Google Contact API:
RequestSettings rs = new RequestSettings("aman contact", Request.QueryString["access_token"].ToString());
rs.AutoPaging = true;
ContactsRequest cr = new ContactsRequest(rs);
PrintAllContacts(cr);
Feed<Contact> f = cr.GetContacts();
Here its giving me following error:
Execution of request failed: http://www.google.com/m8/feeds/contacts/default/full
after this it shows me a yellow page with following error:
The remote server returned an error: (401) Unauthorized.