Announcement Announcement Module
No announcement yet.
Thoughts on how/where to override apiUrlBase, authorizeUrl, accessTokenUrl? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Thoughts on how/where to override apiUrlBase, authorizeUrl, accessTokenUrl?


    When developing my own API, it would be nice to have the ability to override the values for apiUrlBase, authorizeUrl and accessTokenUrl. In the current examples, all of these values are hard coded. While I think this is fine for defaults, I'd like the ability to override those values so that I can test future API changes/additions in another environment.

    Any thoughts on a good place for this type of functionality/logic to exist?

  • #2
    I assume that you mean that you'd like to override these URLs for a given service provider such as Twitter or Facebook? Or did you have something else in mind?

    For example, TwitterServiceProvider sets these via constructor args when it creates the OAuth1Template:

    public class TwitterServiceProvider extends AbstractOAuth1ServiceProvider<Twitter> {
    	public TwitterServiceProvider(String consumerKey, String consumerSecret) {
    		super(consumerKey, consumerSecret, new OAuth1Template(consumerKey, consumerSecret,
    	public Twitter getApi(String accessToken, String secret) {
    		return new TwitterTemplate(getConsumerKey(), getConsumerSecret(), accessToken, secret);
    They are hard-coded in TwitterServiceProvider. But there's nothing stopping you from creating a TestTwitterServiceProvider that uses different URLs and an associated TestTwitterConnectionFactory that instantiates the TestTwitterServiceProvider. Then you could configure that test-oriented connection factory for your testing purposes instead of the one that comes with Spring Social. You could even use Spring 3.1 profiles to configure both of them and pick which one is used based on which profile is active.

    Would it be possible to expose those for configuration? Perhaps add another constructor and/or setters to let you set them to whatever you want? Sure. But there's not much to the connection factory and service provider classes and it's easy enough to just create your own for testing purposes. Given that, I'm not strongly inclined to enable them to be overridden through other means.

    That is, unless you have something else in mind and can convince me otherwise. I'm keeping an open mind.