-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[C++] OAuth 2.0 request's content type is not x-www-form-urlencoded #12334
Labels
type/bug
The PR fixed a bug or issue reported a bug
Comments
Good job in diagnosing this. |
1 task
BewareMyPower
added a commit
that referenced
this issue
Oct 13, 2021
Fixes #12334 ### Motivation When C++ client sends a HTTP request for the access token from a OAuth 2.0 server, the content type is JSON, which is incorrect and might not work in some cases. ### Modifications - Replace `generateJsonBody` with `generateParamMap` to create a map that contains the necessary keys from `CredentialsFlow`. - Add a `buildClientCredentialsBody` method to convert the map to URL encoded string. - Change the content type from `json` to `x-www-form-urlencoded`. ### Verifying this change - [x] Make sure that the change passes the CI checks. This change is already covered by existing tests, such as `AuthPluginTest.testOauth2RequestBody`. This PR changes the test to verify `generateParamMap` because `generateJsonBody` is removed.
tuteng
pushed a commit
that referenced
this issue
Oct 13, 2021
Fixes #12334 ### Motivation When C++ client sends a HTTP request for the access token from a OAuth 2.0 server, the content type is JSON, which is incorrect and might not work in some cases. ### Modifications - Replace `generateJsonBody` with `generateParamMap` to create a map that contains the necessary keys from `CredentialsFlow`. - Add a `buildClientCredentialsBody` method to convert the map to URL encoded string. - Change the content type from `json` to `x-www-form-urlencoded`. ### Verifying this change - [x] Make sure that the change passes the CI checks. This change is already covered by existing tests, such as `AuthPluginTest.testOauth2RequestBody`. This PR changes the test to verify `generateParamMap` because `generateJsonBody` is removed. (cherry picked from commit 4ae7f6a)
bharanic-dev
pushed a commit
to bharanic-dev/pulsar
that referenced
this issue
Mar 18, 2022
…he#12341) Fixes apache#12334 ### Motivation When C++ client sends a HTTP request for the access token from a OAuth 2.0 server, the content type is JSON, which is incorrect and might not work in some cases. ### Modifications - Replace `generateJsonBody` with `generateParamMap` to create a map that contains the necessary keys from `CredentialsFlow`. - Add a `buildClientCredentialsBody` method to convert the map to URL encoded string. - Change the content type from `json` to `x-www-form-urlencoded`. ### Verifying this change - [x] Make sure that the change passes the CI checks. This change is already covered by existing tests, such as `AuthPluginTest.testOauth2RequestBody`. This PR changes the test to verify `generateParamMap` because `generateJsonBody` is removed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
When a HTTP request is sent to an OAuth 2.0 server for an access token, the content type should be
x-www-form-urlencoded
. However, current C++ implementation usesapplication/json
as the content type. Sometimes it works but for some strict validated OAuth 2.0 server, it could fail.To Reproduce
Here are the error logs when sending a request whose content type is
application/json
.The error code is 400, which means bad request.
Expected behavior
The request's content type should be
x-www-form-urlencoded
.The text was updated successfully, but these errors were encountered: