-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Closed
Description
In the Jersey2 Java client, it would be useful to conditionally enable the OAuth2 debug stream when debug is enabled for the client.
For example, with client credentials, the following exception is raised:
java.lang.IllegalArgumentException: Response body is incorrect. Can't extract a token from an empty string
at com.github.scribejava.core.utils.Preconditions.check(Preconditions.java:49)
at com.github.scribejava.core.utils.Preconditions.checkEmptyString(Preconditions.java:31)
at com.github.scribejava.core.extractors.OAuth2AccessTokenJsonExtractor.extract(OAuth2AccessTokenJsonExtractor.java:37)
at com.github.scribejava.core.extractors.OAuth2AccessTokenJsonExtractor.extract(OAuth2AccessTokenJsonExtractor.java:18)
at com.github.scribejava.core.oauth.OAuth20Service.sendAccessTokenRequestSync(OAuth20Service.java:53)
at com.github.scribejava.core.oauth.OAuth20Service.getAccessTokenClientCredentialsGrant(OAuth20Service.java:295)
at ....client.auth.OAuth.obtainAccessToken(OAuth.java:161)
at .....auth.OAuth.applyToParams(OAuth.java:112)
at ....ApiClient.updateParamsForAuth(ApiClient.java:1231)
at ....ApiClient.invokeAPI(ApiClient.java:1048)
...
My suggestion is that at this line:
service = new ServiceBuilder(clientId)
.apiSecret(clientSecret)
.build(authApi);We conditionally add a call to debug():
service = new ServiceBuilder(clientId)
.apiSecret(clientSecret).debug()
.build(authApi);This would make it possible to troubleshoot OAuth2 without running a debugger or changing the library. Since the data may be sensitive, we should have a specific debug flag.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels