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.