The SampleOAuthDataStore from Shindig should work out of the box. I
got it to work with the opensocial java client and the code below.
What also helped me a lot was to turn on logging of the opensocial
java client. You can also look at logs of shindig to get some other
hints.
package nl.q42.oauth;
import java.util.List;
import org.opensocial.Client;
import org.opensocial.Request;
import org.opensocial.Response;
import org.opensocial.auth.AuthScheme;
import org.opensocial.auth.OAuth2LeggedScheme;
import org.opensocial.models.Person;
import org.opensocial.providers.Provider;
import org.opensocial.providers.ShindigProvider;
import org.opensocial.services.PeopleService;
public class ShindigOauthTester {
// See shindig/config/oauth.json
private final static String consumerKey =
"http://localhost:8080/samplecontainer/examples/SocialHelloWorld.xml";
private final static String consumerSecret = "secret";
private final static String openSocialId = "110608369266279337293"; // TODO
public ShindigOauthTester() throws Exception {
Provider provider = new ShindigProvider();
//provider.setAuthorizeUrl("http://localhost:9090/oauth-provider/authorize");
//provider.setAccessTokenUrl("http://localhost:9090/oauth-provider/access_token");
//provider.setRequestTokenUrl("http://localhost:9090/oauth-provider/request_token");
AuthScheme scheme = new OAuth2LeggedScheme(consumerKey,
consumerSecret, openSocialId);
Client client = new Client(provider, scheme);
Request request = PeopleService.getFriends();
Response response = client.send(request);
List<Person> friends = response.getEntries();
for (Person friend : friends) {
System.out.println(friend.getDisplayName());
}
}
public static void main(String[] args) throws Exception {
new ShindigOauthTester();
}
}
On Wed, Oct 13, 2010 at 10:54 AM, Christine Bauers <[email protected]> wrote:
> Thanks for your answer. You´re right. It should be http:// instead of
> http:/ of course. I´ve fixed that and it does not work as well. I´ve read on
> the
> http://opensocial-net-client.googlecode.com/svn-history/r8/trunk/src/OpenSocial.Client/Client/OpenSocialProvider.cs
> site, that I have to use an oauthprovider for shindig from
>
> http://oauth.googlecode.com/svn/code/java
>
> Is this oauthprovider already integrated in shindig or do I have to run it
> seperately?
>
> You have written you was experimenting with 2 legged Oauth. Did you use the
> opensocial java client demo app? And could you maybe give me example?
>
> Greetings
>
>
>
> Am 13.10.2010 10:20, schrieb Christiaan Hees:
>>
>> In shindigoauth.xml you seem to be missing a / on the<Access> part.
>> It should be http:// instead of http:/ so maybe that's related.
>> I was just experimenting with 2 legged OAuth myself and I got it
>> working using the sample implementation that uses oauth info from
>> content/sampledata/canonicaldb.json. I'm not sure if that's also
>> relevant for your case but you might want to check that out.
>>
>> On Tue, Oct 12, 2010 at 9:35 PM, Christine Bauers<[email protected]> wrote:
>>>
>>> Hi shindig users,
>>>
>>> I´m trying to use the android demo app of the open social java client to
>>> connect to Shindig.
>>>
>>> I ´ve deployed the shindig.war on a server. To do this, I´ve named it
>>> ROOT.war and I deleted the ROOT dir.This works. Now I want to open a
>>> connection via the demo app to make some restful calls. To do this, I use
>>> the MyShindigProvider class which extends
>>> org.opensocial.providers.Provider
>>> to set the urls:
>>>
>>> setName("shindig");
>>> setVersion("0.8");
>>> setRestEndpoint("http://server:8081/social/rest/");
>>> setAuthorizeUrl("http://server:8081/oauth/authorize");
>>> setAccessTokenUrl("http://server:8081/oauth/accessToken");
>>> setRequestTokenUrl("http://server:8081/oauth/requestToken");
>>> if (!useRest) {
>>> setRpcEndpoint("http://192.168.1.138:8081/social/rpc/");
>>> }
>>> addRequestTokenParameter("scope", getRequestTokenUrl() + " "
>>> +getRpcEndpoint());
>>> I got these urls from the shindigoauth.xml in samplecontainer/example.Are
>>> these urls correct? Do I maybe have to use https for authorization? And
>>> if,
>>> what are the correct urls then?
>>>
>>> addProvider(new MyShindigProvider(), new String[]
>>> {"http://server:8081/samplecontainer/examples/shindigoauth.xml",
>>> "secret"});
>>>
>>> I got these consumer key and consumer secret from the oauth.json. Are
>>> these
>>> Parameters right or is there another consumer key?
>>>
>>> After this I´ve set the scheme in friendlistclass
>>> setScheme("http://server:8081/gadgets/oauthcallback") to set the callback
>>> url and edited the shindigoauth.xml:
>>>
>>> <Service name="shindig">
>>> <Request url="http://server:8081/oauth/requestToken" />
>>> <Authorization
>>>
>>> url="http://server:8081/oauth/authorize?oauth_callback=http://server:8081/gadgets/oauthcallback"
>>> />
>>> <Access url="http:/server:8081/oauth/accessToken" />
>>> </Service>
>>>
>>> Now I get an OAuthException, because I can´t get any requestToken. . What
>>> did I forget?
>>>
>>> Greetings
>>> Christine Bauers
>>>
>
>
> --
> Christine Bauers, Softwareentwicklung
>
>
> Lyncker& Theis GmbH
> Wilhelmstr. 16
> 65185 Wiesbaden
> Germany
>
> Fon +49 611/9006951
> Fax +49 611/9406125
>
>
> Handelsregister: HRB 23156 Amtsgericht Wiesbaden
> Steuernummer: 4023897051
> USt-IdNr.: DE255806399
>
> Geschäftsführer:
> Filip Lyncker,
> Armin Theis
>
>