Container returned error 401 "unauthorized: Invalid user - using Orkut sandbox

20 views
Skip to first unread message

K. Kumar

unread,
Sep 9, 2009, 11:16:35 AM9/9/09
to opensocial-client-libraries
Hi
I am new in OpenSocial, I am trying with opensocial java client
(which is downloaded from SVN), i have consumer_key and
consumer_secret. When i am trying to connect with orkut container, it
returns 401 unauthorized, invalid user error response even i set my
uid as a valid and correct format. My codes and error msg as follows

Code:
***************************************************************************
OpenSocialClient c =
new OpenSocialClient(OpenSocialProvider.valueOf
("ORKUT_SANDBOX"));
c.setProperty(OpenSocialClient.Property.DEBUG, "true");

// Credentials provided here are associated with the gadget
located at
c.setProperty(OpenSocialClient.Property.CONSUMER_SECRET,
"ydbYye83mSXuTdvdnK1mleyf");
c.setProperty(OpenSocialClient.Property.CONSUMER_KEY,
"orkut.com:516954733659");
c.setProperty(OpenSocialClient.Property.VIEWER_ID,
"11814164769955065835");

try {
// OpenSocialBatch objects are used to bulk multiple OpenSocial
data
// requests so they can be submitted to the container (orkut in
this
// case) in a single HTTP request
OpenSocialBatch batch = new OpenSocialBatch();

batch.addRequest(
OpenSocialClient.newFetchPersonRequest
("11814164769955065835"),
"person");
batch.addRequest(
OpenSocialClient.newFetchFriendsRequest
("11814164769955065835"),
"friends");

// Submit the batch request -- the JSON returned by the
container is
// parsed into an OpenSocialResponse object
OpenSocialResponse resp = batch.send(c);


OpenSocialPerson person = resp.getItemAsPerson("person");
Collection<OpenSocialPerson> friends =
resp.getItemAsPersonCollection("friends");

System.out.println("----------");

// Output the name and ID of the requested person;
System.out.println("Info. for " + person.getDisplayName());
System.out.println("ID: " + person.getId());

OpenSocialField thumbnailUrlField = person.getField
("thumbnailUrl");
if (!thumbnailUrlField.isComplex()) {
System.out.println("Thumbnail URL: " +
thumbnailUrlField.getStringValue());
}

System.out.println("Friends:");

// Iterate through the returned Collection
for (OpenSocialPerson friend : friends) {
// Output the name of the current person
System.out.println("- " + friend.getDisplayName());
}

System.out.println("----------");

} catch (org.opensocial.client.OpenSocialRequestException e) {
System.out.println("OpenSocialRequestException thrown: " +
e.getMessage());
e.printStackTrace();
} catch (java.io.IOException e) {
System.out.println("IOException thrown: " + e.getMessage());
e.printStackTrace();
}
****************************************************************************

Error Msg
****************************************************************************
Container response:
[{"id":"person","error":{"message":"unauthorized: Invalid user, user
lookup returned invalid user.","data":
{"errorType":"invalidUser"},"code":401}},{"id":"friends","error":
{"message":"unauthorized: Invalid user, user lookup returned invalid
user.","data":{"errorType":"invalidUser"},"code":401}}]
OpenSocialRequestException thrown: Container returned error 401
"unauthorized: Invalid user, user lookup returned invalid user." for
request ID "person"
org.opensocial.client.OpenSocialRequestException: Container returned
error 401 "unauthorized: Invalid user, user lookup returned invalid
user." for request ID "person"
at org.opensocial.client.OpenSocialJsonParser.getResponse
(OpenSocialJsonParser.java:82)
at org.opensocial.client.OpenSocialBatch.submitRpc
(OpenSocialBatch.java:152)
at org.opensocial.client.OpenSocialBatch.send(OpenSocialBatch.java:
102)
at org.opensocial.samples.BatchRequests.main(BatchRequests.java:67)

please help..

Thanks
Kumar

Jason (Google)

unread,
Sep 17, 2009, 4:00:29 AM9/17/09
to opensocial-cl...@googlegroups.com
Hi Kumar. Does the orkut user with ID 11814164769955065835 have the gadget corresponding to the consumer key and secret installed on his/her profile?

- Jason

Kumar

unread,
Sep 17, 2009, 5:55:23 AM9/17/09
to opensocial-cl...@googlegroups.com
Hi Jason,

Initially i didn't know how to get my ID from orkut, once i added OSDA, i got correct ID and i can able to get user list. This is my UID (11814164769955065835),  that's why i have gotten 401 Unauthorized i think. After I placed my correct ID it works fine.

Thanks a lot
 

-Kumar

Yatin

unread,
Nov 12, 2009, 11:18:38 PM11/12/09
to opensocial-client-libraries
Hi Kumar,

Even i am facing the same issue mentioned by you. Can you please
ellaborate on how did you got your ID from orkut?

Thanks in advance.

Regards,
Yatin

On Sep 17, 2:55 pm, Kumar <saikumar...@gmail.com> wrote:
> Hi Jason,
>
> Initially i didn't know how to get my ID from orkut, once i added OSDA, i
> got correct ID and i can able to get user list. This is my UID
> (11814164769955065835),  that's why i have gotten 401 Unauthorized i think.
> After I placed my correct ID it works fine.
>
> Thanks a lot
>
> -Kumar
>
>
>
> On Thu, Sep 17, 2009 at 1:30 PM, Jason (Google) <apija...@google.com> wrote:
> > Hi Kumar. Does the orkut user with ID 11814164769955065835 have the gadget
> > corresponding to the consumer key and secret installed on his/her profile?
> > - Jason
>
> >> ***************************************************************************­*
>
> >> Error Msg
>
> >> ***************************************************************************­*
> >> Container response:
> >> [{"id":"person","error":{"message":"unauthorized: Invalid user, user
> >> lookup returned invalid user.","data":
> >> {"errorType":"invalidUser"},"code":401}},{"id":"friends","error":
> >> {"message":"unauthorized: Invalid user, user lookup returned invalid
> >> user.","data":{"errorType":"invalidUser"},"code":401}}]
> >> OpenSocialRequestException thrown: Container returned error 401
> >> "unauthorized: Invalid user, user lookup returned invalid user." for
> >> request ID "person"
> >> org.opensocial.client.OpenSocialRequestException: Container returned
> >> error 401 "unauthorized: Invalid user, user lookup returned invalid
> >> user." for request ID "person"
> >>        at org.opensocial.client.OpenSocialJsonParser.getResponse
> >> (OpenSocialJsonParser.java:82)
> >>        at org.opensocial.client.OpenSocialBatch.submitRpc
> >> (OpenSocialBatch.java:152)
> >>        at org.opensocial.client.OpenSocialBatch.send(OpenSocialBatch.java:
> >> 102)
> >>        at org.opensocial.samples.BatchRequests.main(BatchRequests.java:67)
>
> >> please help..- Hide quoted text -
>
> - Show quoted text -

Jason (Google)

unread,
Nov 13, 2009, 6:14:49 PM11/13/09
to opensocial-cl...@googlegroups.com
For testing purposes, you can get your own personal ID using the OpenSocial JavaScript API. Probably the easiest way to do this is by installing OSDA on your profile:


Then change the default sample to output the ID instead of the display name.

If you're using this in a real-world app and you need to get the current viewer's ID, it gets more complicated. You're better off waiting until orkut supports 3-legged OAuth.

- Jason

Yatin Kumar Singh

unread,
Nov 17, 2009, 3:21:00 AM11/17/09
to opensocial-cl...@googlegroups.com
Thanks Jason for the reply. But i am very new to javascript APIs. Can you please guide me on how i can OSDA on my profile.
 
Regards,
Yatin


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "opensocial-client-libraries" group.
To post to this group, send email to opensocial-cl...@googlegroups.com
To unsubscribe from this group, send email to opensocial-client-l...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/opensocial-client-libraries?hl=en
-~----------~----~----~----~------~----~------~--~---




--
नमस्कार,
यतिन कुमार सिंह
मोब :- +44+7944677925

Jason (Google)

unread,
Nov 17, 2009, 5:16:40 PM11/17/09
to opensocial-cl...@googlegroups.com
Just click the orkut icon on the http://osda.appspot.com/ page and it should take you to the install page. Once it's there, just run the default script and it should show your name. Modify getDisplayName() to getId() and you'll see your OpenSocial ID which you can use with the client library.

- Jason

--

You received this message because you are subscribed to the Google Groups "opensocial-client-libraries" group.
To post to this group, send email to opensocial-cl...@googlegroups.com.
To unsubscribe from this group, send email to opensocial-client-l...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/opensocial-client-libraries?hl=.

Bruno

unread,
Dec 8, 2009, 9:36:14 PM12/8/09
to opensocial-client-libraries
Hi,

i have same problem: My app working, but now... 401

little test:

final OpenSocialProvider provider = OpenSocialProvider.valueOf
("ORKUT_SANDBOX");
final OpenSocialClient client = new OpenSocialClient(provider);
client.setProperty
(OpenSocialClient.Property.CONSUMER_SECRET,"orkut.com:330367315017");
client.setProperty(OpenSocialClient.Property.CONSUMER_KEY,
"+HMbb5hOE8fj1JL5gbfko3X4");
client.setProperty(OpenSocialClient.Property.VIEWER_ID,
"16660332831789931962");
client.setProperty(OpenSocialClient.Property.DEBUG, "true");
OpenSocialPerson person = null;
try {
person = client.fetchPerson();
} catch (OpenSocialRequestException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if (person!=null)
System.out.println(person.getDisplayName());
}

the viewer's id is my orkut id, in the past, working - a version of
opensocial java client is 20090402

Jason (Google)

unread,
Dec 8, 2009, 9:40:08 PM12/8/09
to opensocial-cl...@googlegroups.com
It looks like you might have swapped your consumer key and secret. The consumer key is prefixed with orkut:, not the secret.

- Jason

--

You received this message because you are subscribed to the Google Groups "opensocial-client-libraries" group.
To post to this group, send email to opensocial-cl...@googlegroups.com.
To unsubscribe from this group, send email to opensocial-client-l...@googlegroups.com.

Bruno

unread,
Dec 9, 2009, 1:23:15 PM12/9/09
to opensocial-client-libraries
Oh my...,

I fix:

final OpenSocialProvider provider = OpenSocialProvider.valueOf
("ORKUT_SANDBOX");
final OpenSocialClient client = new OpenSocialClient(provider);
client.setProperty
(OpenSocialClient.Property.CONSUMER_SECRET,"+HMbb5hOE8fj1JL5gbfko3X4");
client.setProperty(OpenSocialClient.Property.CONSUMER_KEY,
"orkut.com:330367315017");
client.setProperty(OpenSocialClient.Property.VIEWER_ID,
"16660332831789931962");
client.setProperty(OpenSocialClient.Property.DEBUG, "true");
OpenSocialPerson person = null;
try {
person = client.fetchPerson();
} catch (OpenSocialRequestException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if (person!=null)
System.out.println(person.getDisplayName());


, and...

Signature base string:
POST&http%3A%2F%2Fsandbox.orkut.com%2Fsocial%2Frpc&oauth_body_hash
%3DDXcWveBSx5z1Ac%252BRnI0aD8dyfRk%253D%26oauth_consumer_key
%3Dorkut.com%253A330367315017%26oauth_nonce
%3D2599867028072%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp
%3D1260386099%26oauth_version%3D1.0%26xoauth_requestor_id
%3D16660332831789931962
java.io.IOException: Container returned status 401 "Server returned
HTTP response code: 401 for URL:
http://sandbox.orkut.com/social/rpc?oauth_signature=p5sixSMhm34stk3g%2FPFheYExrd4%3D&oauth_version=1.0&oauth_nonce=2599867028072&oauth_body_hash=DXcWveBSx5z1Ac%2BRnI0aD8dyfRk%3D&oauth_signature_method=HMAC-SHA1&oauth_consumer_key=orkut.com%3A330367315017&xoauth_requestor_id=16660332831789931962&oauth_timestamp=1260386099"

thanks

Bruno
> > opensocial-client-l...@googlegroups.com<opensocial-client- libraries%2Bunsu...@googlegroups.com>
> > .

Jason (Google)

unread,
Dec 9, 2009, 1:43:20 PM12/9/09
to opensocial-cl...@googlegroups.com
I added the orkut application corresponding to your consumer key to my personal profile and modified DisplayProfileData.java to use your consumer key and secret and everything worked for me. Please make sure that the viewer ID that you're using is an OpenSocial ID (not an orkut ID) and that the corresponding orkut profile has the RSGuia - Desenvolvimento app installed.

- Jason

To unsubscribe from this group, send email to opensocial-client-l...@googlegroups.com.

Bruno

unread,
Dec 11, 2009, 6:19:32 PM12/11/09
to opensocial-client-libraries
Hello Jason,

Man, I'm going crazy ...

In the "live" app, the error is:
java.io.IOException: Container returned status 403 "Server returned
HTTP response code: 403 for URL:
http://www.orkut.com/social/rest/people/07047645628855411297/@self?oauth_signature=atRRuzfgF1Tl0rN7C6H%2FklBhjvw%3D&oauth_version=1.0&oauth_nonce=138098099322499&oauth_signature_method=HMAC-SHA1&oauth_consumer_key=orkut.com%3A209725486077&xoauth_requestor_id=07047645628855411297&oauth_timestamp=1260522173&fields=name%2Cstatus%2CthumbnailUrl"
at org.opensocial.client.OpenSocialHttpClient.send
(OpenSocialHttpClient.java:118)

My OpenSocial ID is 16660332831789931962, i caught in OpenSocial Dev
App (orkut) and i have the RSGuia app instaled in the Orkut and Orkut
Sandbox, but, in developer time is 401, and the production time, is
403.



On 9 dez, 15:43, "Jason (Google)" <apija...@google.com> wrote:
> I added the orkut application corresponding to your consumer key to my
> personal profile and modified DisplayProfileData.java to use your consumer
> key and secret and everything worked for me. Please make sure that the
> viewer ID that you're using is an OpenSocial ID (not an orkut ID) and that
> the corresponding orkut profile has the RSGuia - Desenvolvimento app
> installed.
>
> - Jason
>
> >http://sandbox.orkut.com/social/rpc?oauth_signature=p5sixSMhm34stk3g%...
> > > > opensocial-client-l...@googlegroups.com<opensocial-client-libraries%2Bunsu...@googlegroups.com><opensocial-client-
> > libraries%2Bunsu...@googlegroups.com<libraries%252Buns...@googlegroups.com>
>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/opensocial-client-libraries?hl=en.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "opensocial-client-libraries" group.
> > To post to this group, send email to
> > opensocial-cl...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > opensocial-client-l...@googlegroups.com<opensocial-client-libraries%2Bunsu...@googlegroups.com>

Jason (Google)

unread,
Dec 11, 2009, 9:02:05 PM12/11/09
to opensocial-cl...@googlegroups.com
Hi Bruno. Can you reply (either publicly or privately) with your orkut profile URL and make sure OSDA (http://osda.appspot.com) is installed on it?

- Jason

To unsubscribe from this group, send email to opensocial-client-l...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages