Permalink
Browse files

Adding TumblrTemplate constructor for non user-authenticated api use …

…where credentials are null, and modifying request interceptor so it allows for null credentials
  • Loading branch information...
1 parent 13d15e7 commit 5ba35dad75a355ad46dc2d80b5a435f79dd3f1df @michaellavelle michaellavelle committed with Aug 19, 2012
@@ -27,7 +27,10 @@ public TumblrOAuth1RequestInterceptor(TumblrTemplate tumblrTemplate) {
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
HttpRequest protectedResourceRequest = new HttpRequestDecorator(request);
- protectedResourceRequest.getHeaders().add("Authorization", getAuthorizationHeaderValue(request, body));
+ if (tumblrTemplate.isAuthorized())
+ {
+ protectedResourceRequest.getHeaders().add("Authorization", getAuthorizationHeaderValue(request, body));
+ }
return execution.execute(protectedResourceRequest, body);
}
@@ -29,6 +29,12 @@ public TumblrTemplate(String consumerKey, String consumerSecret, String accessTo
credentials = new TumblrOAuth1Credentials(consumerKey, consumerSecret, accessToken, accessTokenSecret);
initApis();
}
+
+ public TumblrTemplate(String consumerKey) {
+ super();
+ this.apiKey = consumerKey;
+ initApis();
+ }
public TumblrOAuth1Credentials getCredentials() {
return credentials;

0 comments on commit 5ba35da

Please sign in to comment.