Permalink
Browse files

OAuth response type is changeable

  • Loading branch information...
1 parent 1d5e107 commit efc331b8c360bbb3e05d2c09e19fc5f6999569ef @shred committed Apr 27, 2012
View
12 flattr4j-core/src/main/java/org/shredzone/flattr4j/oauth/FlattrAuthenticator.java
@@ -42,6 +42,7 @@
private String requestTokenUrl = "https://flattr.com/oauth/authorize";
private String accessTokenUrl = "http://flattr.com/oauth/token";
+ private String responseType = "code";
private String callbackUrl = null;
@@ -71,6 +72,15 @@
public void setScope(EnumSet<Scope> scope) { this.scope = scope; }
/**
+ * The OAuth response type. This is {@code code} or {@code token}, with the former
+ * being the default.
+ *
+ * @since 2.3
+ */
+ public void setResponseType(String responseType) { this.responseType = responseType; }
+ public String getResponseType() { return responseType; }
+
+ /**
* Constructs a new instance with the given {@link ConsumerKey}.
*
* @param consumerKey {@link ConsumerKey}
@@ -140,7 +150,7 @@ public String authenticate(String state) throws FlattrException {
try {
StringBuilder url = new StringBuilder();
url.append(requestTokenUrl);
- url.append("?response_type=code");
+ url.append("?response_type=").append(URLEncoder.encode(responseType, ENCODING));
url.append("&client_id=").append(URLEncoder.encode(consumerKey.getKey(), ENCODING));
if (callbackUrl != null) {

0 comments on commit efc331b

Please sign in to comment.