Announcement Announcement Module
Collapse
No announcement yet.
Possible problem with OAuth2Template? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Possible problem with OAuth2Template?

    Craig,

    When I am trying to configure my OAuth2Template, I do the following:

    Code:
    		OAuth2Template oAuth2Template = new OAuth2Template(clientId, clientSecret, "someAuthenticateUrl", "someAccessTokenUrl");
    		oAuth2Template.setUseParametersForClientAuthentication(true);
    The problem is in the constructor of the OAuth2Template. Look at the following:
    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));
    		}
    	}
    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).

    This has created some headaches when writing a new social API. Thoughts?

    -Joshua

  • #2
    You know...I think you're right about this. If you don't mind, could you open a Jira bug issue on this and I'll give it a look.

    (Note that I'm 2 days away from starting a long-overdue family vacation, so I may not give it a look until late next week or the week after.)

    Comment


    • #3
      All set. Here is a link to the but: https://jira.springsource.org/browse/SOCIAL-338

      Regards,

      Joshua

      Comment

      Working...
      X