hrishikeshp19
hrishikeshp19

Reputation: 9028

grails oAuth 2.0 documentation?

I am going through http://aiten.github.com/grails-oauth-scribe/guide/usingThePlugin.html

My main problem is, I have my linkedin access token, but this API forces me to use

Token linkedInAccessToken = oauthService.findSessionKeyForAccessToken('linkedin')

I want to init Token object with a string.

I could not find the API documentation anywhere, please help

Upvotes: 0

Views: 228

Answers (3)

Antony Jones
Antony Jones

Reputation: 3180

Edvinas has it - the Token object (from Scribe) allows init as he specifies.

There is also an optional third parameter, which is the entire raw oauth response from the server, useful if you want to grab/store expiration info etc.

Also as Jeff says, the plugin is designed such that you can happily use the token throughout without worrying about it - it's much cleaner to store objects as object rather than a String, and might help avoid strange runtime errors in your code.

If you want to store it as a Map you should serialize it as such first.

Source: I wrote the plugin.

Upvotes: 1

Edvinas Bartkus
Edvinas Bartkus

Reputation: 467

I guess you want to persist the token object. It consists two Sting fiekds: token and secret. When you have them stored in the database you can always create the token simply:

Token linedInAcessToken = new org.scribe.model.Token(token, secret)

This can be later used in oauthService.

Upvotes: 0

Jeff Beck
Jeff Beck

Reputation: 3938

If you already have the access token you wouldn't need to really do the oauth request you could just make the request with token you have. Below change linkedInAccessToken to the string that has the token.

    oauthService.postLinkedInResource(linkedInAccessToken, 'http://api.yourprovider.com/users/list')

Upvotes: 0

Related Questions