Craig,
When I am trying to configure my OAuth2Template, I do the following:
The problem is in the constructor of the OAuth2Template. Look at the following:Code:OAuth2Template oAuth2Template = new OAuth2Template(clientId, clientSecret, "someAuthenticateUrl", "someAccessTokenUrl"); oAuth2Template.setUseParametersForClientAuthentication(true);
As part of the constructor invocation, we are automatically adding a PreemptiveBasicAuthClientHttpRequestInterceptor before we get the chance to set the value of the useParametersForClientAuthentication variable to "true". As a result, this interceptor will always get added regardless of whether or not I call oAuth2Template.setUseParametersForClientAuthentica tion(true).Code:public OAuth2Template(String clientId, String clientSecret, String authorizeUrl, String authenticateUrl, String accessTokenUrl) { Assert.notNull(clientId, "The clientId property cannot be null"); Assert.notNull(clientSecret, "The clientSecret property cannot be null"); Assert.notNull(authorizeUrl, "The authorizeUrl property cannot be null"); Assert.notNull(accessTokenUrl, "The accessTokenUrl property cannot be null"); this.clientId = clientId; this.clientSecret = clientSecret; String clientInfo = "?client_id=" + formEncode(clientId); this.authorizeUrl = authorizeUrl + clientInfo; if (authenticateUrl != null) { this.authenticateUrl = authenticateUrl + clientInfo; } else { this.authenticateUrl = null; } this.accessTokenUrl = accessTokenUrl; this.restTemplate = createRestTemplate(); if (!useParametersForClientAuthentication) { restTemplate.getInterceptors().add(new PreemptiveBasicAuthClientHttpRequestInterceptor(clientId, clientSecret)); } }
This has created some headaches when writing a new social API. Thoughts?
-Joshua


Reply With Quote