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