Skip to content

Commit 419f405

Browse files
authored
Merge pull request #60 from psytester/patch-4
RFC conform handling for grant_type=refresh_token without code
2 parents 76b3a20 + 3fcb1ca commit 419f405

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/main/java/com/docusign/esign/client/auth/OAuthJerseyClient.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder;
1313
import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
1414
import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
15+
import org.apache.oltu.oauth2.common.message.types.GrantType;
1516
import com.sun.jersey.api.client.WebResource.Builder;
1617
import com.sun.jersey.api.client.Client;
1718
import com.sun.jersey.api.client.ClientResponse;
@@ -53,13 +54,20 @@ public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map
5354
clientSecret = value;
5455
}
5556
}
56-
57-
if (grantType == null || code == null) {
58-
throw new OAuthSystemException("Missing grant_type/code");
57+
58+
if (grantType == null) {
59+
throw new OAuthSystemException("Missing grant_type");
60+
}
61+
if (!grantType.equals(GrantType.REFRESH_TOKEN.toString()) && code == null) {
62+
throw new OAuthSystemException("Missing code for grant_type="+grantType);
63+
}
64+
65+
if (code == null) {
66+
body = "grant_type=" + grantType;
5967
} else {
6068
body = "grant_type=" + grantType + "&code=" + code;
6169
}
62-
70+
6371
if (clientId == null || clientSecret == null) {
6472
throw new OAuthSystemException("Missing clientId/secret");
6573
} else {
@@ -113,4 +121,4 @@ public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map
113121
public void shutdown() {
114122
// Nothing to do here
115123
}
116-
}
124+
}

0 commit comments

Comments
 (0)