I'm trying to run a groovy script that calls the Linkedin API. The question is, how do I authenticate using the grails oauth plugin from within the groovy script ? This is my config :
oauth {
linkedin {
requestTokenUrl="https://api.linkedin.com/uas/oauth/requestToken"
accessTokenUrl="https://api.linkedin.com/uas/oauth/accessToken"
authUrl="https://www.linkedin.com/uas/oauth/authenticate"
consumer.key="xxxxxxxxx"
consumer.secret="xxxxxxxxxx"
}
}
This is my script, which I start with "grails run-script scriptname.groovy" :
import org.grails.plugins.oauth.OauthService
def oauthService = new OauthService()
oauthService.reset()
def URL = "http://api.linkedin.com/v1/people-search?country-code=us&postal-code=98102&distance=100&start=0&count=5"
def recs_response = oauthService.accessResource( URL, "linkedin", [key:"xxxxxxx", secret:"xxxxxxxxx"], 'GET')
println "it worked"
If I print the response I get "The token used in the OAuth request is not valid"
Thanks.
Take a look at http://code.google.com/p/oauth-signpost/wiki/TwitterAndSignpost
I downloaded the OAuthTwitterExample and put the commons-codec-1.3.jar and signpost-core-1.1-SNAPSHOT.jar that were included in the zip in my working directory
for flickr OAuth I used the following in oauth.groovy
enter this on commandline in the working directory
hope this helps