Announcement Announcement Module
Collapse
No announcement yet.
Client support changes - feedback request Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Client support changes - feedback request

    There were some significant changes to the client support features last week and some feedback would be good from anyone who is using s2-oauth in a client app. See in particular the new constructors and public methods in OAuth2RestTemplate...

    For a client with an existing access token:

    Code:
    OAuth2ProtectedResourceDetails resource = ...;
    OAuth2ClientContext context = new DefaultOAuth2ClientContext(accessToken);
    OAuth2RestTemplate template = new OAuth2RestTemplate(resource, context);
    // ... now use template as a normal RestTemplate
    For a client that needs to obtain a token but has all the credentials needed:

    Code:
    OAuth2ProtectedResourceDetails resource = ...;
    OAuth2ClientContext context = new DefaultOAuth2ClientContext(new AccessTokenRequest(parameters));
    OAuth2RestTemplate template = new OAuth2RestTemplate(resource, context);
    // ... now use template as a normal RestTemplate
    There are some tweaks in the pipeline to make this last example work better with implicit and auth code grants. Password and client credentials should be OK already.

    A webapp client can create a rest template and inject a OAuth2ClientContext in session scope to get the same behaviour as before the change, and there is a new namespace element to support this in a convenient way, e.g. (from tonr2):

    Code:
    	<bean id="sparklrService" class="org.springframework.security.oauth.examples.tonr.impl.SparklrServiceImpl">
                    ...
    		<property name="sparklrRestTemplate">
    			<oauth:rest-template resource="sparklr" />
    		</property>
    		<property name="trustedClientRestTemplate">
    			<oauth:rest-template resource="trusted" />
    		</property>
    	</bean>
Working...
X