Skip to content

Commit f7f390a

Browse files
committed
OAuth 1 APIs can choose whether to pass empty oauth_token param in requests
1 parent 0f39939 commit f7f390a

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

changelog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Stack Exchange authentication via OAuth 2.0 (stackoverflow.com, askubuntu.com, etc.).
33
* Support response in gzip.
44
* differentiate OAuth1 Access token, OAuth 1 Request Token and OAuth 2 Access token, make them conforms RFCs
5+
* OAuth 1 APIs can choose whether to pass empty oauth_token param in requests
56

67
[2.2.2]
78
* make all APIs to be extentable (have protected constructors, useful for testing)

scribejava-core/src/main/java/com/github/scribejava/core/builder/api/DefaultApi10a.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,14 @@ public Verb getRequestTokenVerb() {
129129
public OAuth10aService createService(OAuthConfig config) {
130130
return new OAuth10aService(this, config);
131131
}
132+
133+
/**
134+
* http://tools.ietf.org/html/rfc5849 says that "The client MAY omit the empty "oauth_token" protocol parameter from
135+
* the request", but not all oauth servers are good boys.
136+
*
137+
* @return whether to inlcude empty oauth_token param to the request
138+
*/
139+
public boolean isEmptyOAuthTokenParamIsRequired() {
140+
return false;
141+
}
132142
}

scribejava-core/src/main/java/com/github/scribejava/core/oauth/OAuth10aService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ public void signRequest(OAuth1AccessToken token, AbstractRequest request) {
130130
final OAuthConfig config = getConfig();
131131
config.log("signing request: " + request.getCompleteUrl());
132132

133-
// Do not append the token if empty. This is for two legged OAuth calls.
134-
if (!token.isEmpty()) {
133+
if (!token.isEmpty() || api.isEmptyOAuthTokenParamIsRequired()) {
135134
request.addOAuthParameter(OAuthConstants.TOKEN, token.getToken());
136135
}
137136
config.log("setting token to: " + token);

0 commit comments

Comments
 (0)