- changed status to open
GrantType Parse Exception
I try to implement OAuth2 TOKEN Endpoint with java servlet, the sample code as follows
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
final HTTPRequest httprequest = new HTTPRequest(request);
final TokenRequest tokenrequest = TokenRequest.parse(httprequest);
AuthorizationGrant ag = tokenrequest.getAuthorizationGrant();
System.out.println("Grant Type : " + ag.getType().getValue());
final ClientSecretBasic clientsecretbasic = (ClientSecretBasic)tokenrequest.getClientAuthentication();
System.out.println("Client ID : " + clientsecretbasic.getClientID() + " Client Secret : " + clientsecretbasic.getClientSecret().getValue());
} catch (ParseException | IOException ex) {
System.out.println(ex);
}
}
When I using Google OAuth2 Playground to fetch the token , it failed and show error message below:
com.nimbusds.oauth2.sdk.ParseException: Unsupported grant type: authorization_code
But when I look back to the source code, I could not figure what's wrong. The attachments it the log.
Comments (7)
-
-
Added GrantType.equals tests, all pass (commit eaab471).
-
Added new AuthorizationCodeGrant.parse test (commit 5caa27a), all pass.
-
Added AuthorizationGrant.parse test (commit 9fbb06a), all tests pass.
-
I'm not able to reproduce the exception, despite adding a number of extra tests to check the GrantType equality method.
Could you do a print out of the HTTP request URL, parameters and body, and post them here?
Cheers,
Vladimir
-
reporter Dears
I found the problem, that's HTTPRequest object add line separator as described in Issue #81.
So if I put the grant_type parameter at tail, the parser will raise the exception!
-
- changed status to invalid
Exception caused by issue
#81. - Log in to comment
Thanks for reporting this. I will check the code and run a few tests.