0

I have user credentials of user gmail account, from that I have to retrieve access_token. How to do that? I've checked in google but couldn't find any solution.

my final objective: I'm trying to fetch the contact profile picture from gmail. I think that the image can be downloaded by requesting https://www.google.com/m8/feeds/photos/media/default/{contactId} but it requires the access token.

I have tried the example given in the google contacts documentation:

1st try

public static void DownloadPhoto(ContactsRequest cr, Uri contactURL)
{
  Contact contact = cr.Retrieve<Contact>(contactURL);

  Stream photoStream = cr.GetPhoto(contact);
  FileStream outStream = File.OpenWrite("test.jpg");
  byte[] buffer = new byte[photoStream.length];

  photoStream.Read(buffer, 0, photoStream.length);
  outStream.Write(buffer, 0, photoStream.length);
  photoStream.Close();
  outStream.Close();
}

in this am getting the photoStream object null

2nd try

Contact contact = ContactsRequest.get("https://www.google.com/m8/feeds/photos/media/default/<contactId>");

in this method am getting a parser error

Please suggest any links or example to retrieve photo from gmail contact or to get access token from user credentials. Thank you.

Alex Netkachov
  • 13,172
  • 6
  • 53
  • 85
  • What do you mean by user credentials? I think the users profile picture can be grabbed though the Google+ api. You should check out the Google .net client lib it makes things a lot easer. – Linda Lawton - DaImTo Sep 12 '14 at 06:36
  • user credentials in the sense username and password of gmail. i need to fetch the contacts picture in gmail account. not google+ profile picture – Ragunath Venkatesan Sep 12 '14 at 14:13

0 Answers0