Getting contact photo from Contacts v3

776 views
Skip to first unread message

tiegz

unread,
Feb 3, 2012, 5:30:57 PM2/3/12
to google-co...@googlegroups.com
Hi, I'm migrating some code from Portable Contacts api to Contacts v3 api. 

Previously, we'd store contact photos by their public url ("thumbnailUrl" from Portable Contacts).

It looks like Contacts v3 only gives you a photo url that's protected behind your access_token. Is that the only way to get a contact photo? We probably won't upgrade to v3 unless we can get a public url :\ 

Thanks,

-tieg

Wojciech Mąka

unread,
Feb 6, 2012, 4:05:23 AM2/6/12
to google-co...@googlegroups.com
Exactly - it seems its very protected, It is protected so hardly that I even can not retrieve contact photo even after sending oauth signed (3-legged) requests. In fact there is no way for me to retrieve contact photo - that is why I'm sad.  As to Your question I can only say that imho there is no such way to get image without authentication. Btw I think I will have to try this Portable Contacts API to retrieve contact Image, maybe then I'll be successfull.


Teresa Ali

unread,
Feb 6, 2012, 8:57:30 AM2/6/12
to google-co...@googlegroups.com
HI

Thank you for taking a look at this. Please if there is something that I can do to help you to retrieve the contact photo and I am assuming that is it my header on the front page.
If I can help please let me know.  I don't understand why you can't retrieve that. 

FYI:  Not sure if this will help you or not but I changed the header from the original one thru a photo editing software.  I hope this helps you.

I don't know about this sort of thing.  So if you want me to do something you will need to give me step by step instructions. 

Please let me know if you need my help

Thank you for looking into this.

Teresa

2012/2/6 Wojciech Mąka <wojcie...@outbox.pl>
Exactly - it seems its very protected, It is protected so hardly that I even can not retrieve contact photo even after sending oauth signed (3-legged) requests. In fact there is no way for me to retrieve contact photo - that is why I'm sad.  As to Your question I can only say that imho there is no such way to get image without authentication. Btw I think I will have to try this Portable Contacts API to retrieve contact Image, maybe then I'll be successfull.


--
You received this message because you are subscribed to the Google
Groups "Google Contacts, Shared Contacts and User Profiles APIs" group.
To post to this group, send email to
google-co...@googlegroups.com
To unsubscribe from this group, send email to
google-contacts...@googlegroups.com
For more options, visit this group at
http://code.google.com/apis/contacts/community/forum.html

Wojciech Mąka

unread,
Feb 8, 2012, 8:35:09 AM2/8/12
to google-co...@googlegroups.com
Hello Teresa,

When I'm doing this code : 

GoolgeOAuthParameters oauthParameters = tokenManager.getAuthParameters(email);
OAuthConsumer consumer = new DefaultOAuthConsumer(oauthParameters.getOAuthToken(),oauthParameters.getOAuthTokenSecret);
URL url = new URL(resource);
HttpURLConnection request = (HttpURLConnection)url.openConnection();
consumer.sign(request);
request.connect();
request.getInputStream(); 

I should get a stream of bytes from google - which is an image. The problem is that despite of fact I'm signing requests with oauth parameters (using auth post) I'm getting exception caused by 401 response. 
Maybe I've found solution but haven't got  time to give it a try... My problem may be caused by incorrect  scope im using during "oauth dance" ... I'm using https://google.com/m8/feeds/contacts - but images are under https://www.google.com/m8/feeds/photo this is different path - therefore the scope for photos may not be included in  oauth access. I will try antoher scope  - https://google.com/m8/feeds and maybe then I'll succeed. If it works I'll post a comment. 

Wojciech Mąka

unread,
Feb 9, 2012, 3:41:39 AM2/9/12
to google-co...@googlegroups.com
No the scope   https://www.google.com/m8/feeds/photo seems to be incorrect. I'm stuck. Really there is no way to fetch an image from contact entry from google. I've tried 2 methods:
1. by using entry.getContactLinkPhoto() and then service.createLinkQueryRequest(photoLink).execute() (thenr reading from ResponseStream) - the error was No authentication header information - but how can it be If I managed to download the entire contact (so the auth is correct)
2. By using auth post and the code from my previous post. - then the exception is raised saying there was a problem with authentication - which is caused for sure by the same reason that in createLinkQueryRequest()

I understand that the api  which provides the method createLinkQueryRequest can have a bug but the second "low level" approach should then pass, but it doesn't. Setting scope only for contacts before authentication also is correct as photos are included in this scope. So what am I missing here ? what is wrong in my code ?  

Wojciech Mąka

unread,
Feb 9, 2012, 6:21:30 AM2/9/12
to google-co...@googlegroups.com
OK I do not know How, but finally I recompiled all subprojects , have done  "turn off and turn on again" - like stuff and everything is working !!!!!!!!!!!!!!!!!!!  

Teresa Ali

unread,
Feb 9, 2012, 9:34:35 AM2/9/12
to google-co...@googlegroups.com
Thank you for working so hard on this.
I do appreciate it.

So This has been fixed now,  Am I Correct?
Teresa

2012/2/9 Wojciech Mąka <wojcie...@outbox.pl>
OK I do not know How, but finally I recompiled all subprojects , have done  "turn off and turn on again" - like stuff and everything is working !!!!!!!!!!!!!!!!!!!  

rudresh dave

unread,
Mar 21, 2012, 10:42:07 AM3/21/12
to google-co...@googlegroups.com
I am facing a problem with retrieving contact's photo. I'm getting a "The remote server returned an error: (401) Unauthorized." with an inner exception of "Token invalid -Invalid token: Cannot parse AuthSub token"

Help me out...

On Thursday, February 9, 2012 8:04:35 PM UTC+5:30, Teresa Ali wrote:
Thank you for working so hard on this.
I do appreciate it.

So This has been fixed now,  Am I Correct?
Teresa

2012/2/9 Wojciech Mąka <wojcie...@outbox.pl>
OK I do not know How, but finally I recompiled all subprojects , have done  "turn off and turn on again" - like stuff and everything is working !!!!!!!!!!!!!!!!!!!  

--
You received this message because you are subscribed to the Google
Groups "Google Contacts, Shared Contacts and User Profiles APIs" group.
To post to this group, send email to

To unsubscribe from this group, send email to
Reply all
Reply to author
Forward
0 new messages