5 Upgrading from grails-oauth - Reference Documentation
Authors: Antony Jones
5 Upgrading from grails-oauthgrails-oauth vesion 2.x is a ground-up rewrite of the previous plugin (< 1.x), with a number of small differences in its set-up.This quick guide will attempt to make the transition as seamless as possible.
ConfigurationThe configuration block's structure remains mainly the same, with the important changes documented below
|Old Configuration Directive||New Configuration Directive|
|requestTokenUrl||Replaced with 'api' directive, see 3. Further Configuration|
|accessTokenUrl||Replaced with 'api' directive, see 3. Further Configuration|
|authUrl||Replaced with 'api' directive, see 3. Further Configuration|
The plugin does not currently support multiple consumers, it is recommended to set up multiple providers with different names if you need this functionality.
In the view layer (GSP)The oauth link tag has become much more simplified:
<g:oauthLink consumer='myConsumer' returnTo="[controller: 'myController', action: 'oauthComplete']">Authorize</g:oauthLink>
The 'returnTo' directive above has been moved into your configuration as 'successUri' and 'failureUri'. See 3. Further Configuration for further details.
Accessing oauth protected resourcesAccessing resources is now done via convention rather than configuration, so the following block of code
can be implemented as
def response = oauthService.accessResource(url: 'http://api.url', consumer: 'twitter', token:[key: 'accesskey', secret: 'accesssecret'], method: 'POST')
where 'Twitter' is the provider name, twitterAccessToken is an instance of
def response = oauthService.postTwitterResource(twitterAccessToken, 'http://api.url')
org.scribe.model.Tokenand the second parameter is the url of the oauth protected resource you are trying to access.