Search code examples
javagrailsoauthspring-securityoauth-provider

Store access token on my Grails OAuth provider using Spring Security 3


I've just implemented a oAuth provider for my Grails application, and can sucessfully authenticate my client application (using signpost). The next thing I want to do is persist the access token, so my client doesn't have to accept permission everytime. On the server I use the Spring Security OAuth package.

I guess I have to implement my own OAuthProviderTokenServices but I'm not sure. Is there any out-of-the-box handler that I can use, or what is the way to go?

Thanx!!


Solution

  • There is an out of the box provider for OAuth2 (JdbcOAuth2ProviderTokenServices) but it looks like there is not a comparable class for OAuth 1. Your best bet would be to subclass RandomValueProviderTokenServices and implement the three abstract persistence related methods. Take a look at JdbcOAuth2ProviderTokenServices for code to borrow, especially around serializing the Authentication object.

    I implemented a custom JPA backed OAuth2ProviderTokenServices in a similar way and it was pretty easy.