-
-
Notifications
You must be signed in to change notification settings - Fork 489
Client web application does no longer send client_id #585
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
Comments
My first thinking is to revert back the changes in Finally, to replace the original fix, I'll suggest to remove Thoughts? |
I actually triggered this same issue in one of my tests, but filed it against requests/oauthlib here: requests/requests-oauthlib#330 I believe the issue is actually the fault of requests_oauthlib. Their docs - actually the first example in their entire docs when you load the page - support specifying the |
@jvanasco, the current issue #585 can be fixed in requests-oauthlib alone, or by reverting oauthlib's PR #505. However, none of the solution will fix the behavior mentioned by @skion in his comment at #505 (comment)
Oauthlib must provide an elegant and simple way for requests-oauthlib to solve the problem. If we can find a solution in this discussion it will be great; because that's a huge blocker. |
Would allowing
|
Ah, I see. Is there an existing unit-test for when client_id should be sent vs not? If not, does anyone have a listing that can be used to generate one? I'd be happy to take a stab at fixing this and requests-oauthlib, because it's blocking some of my work right now. |
Reading this back, I actually quite like your suggestion. We can probably get away doing it in a non-breaking way, since the function already takes One note:
Since this is about public clients IIUC, I wouldn't think the |
Indeed ! @jvanasco, if you want to do a PR I think the changes should be:
Then, requests-oauthlib will have the choice in https://github.com/requests/requests-oauthlib/blob/master/requests_oauthlib/oauth2_session.py#L196-L211 to either: self._client.prepare_request_body(..) B) Include self._client.prepare_request_body(include_client_id=False, ..)
auth = requests.auth.HTTPBasicAuth(client_id, client_secret) C) Include self._client.prepare_request_body(client_secret=client_secret, ..) |
I'll generate PR's for both projects today. |
I've pretty much got a PR and tests done for OAuthlib. I have a question though... Should |
Wouldn't see how you'd ever want to override Should we, in addition, log a |
* `prepare_request_body` client_id is deprecated in favor of include_client_id * a new unit test `test_prepare_request_body` is added to ensure conformity of several use cases * the docstrings for the `body` param have been consolidated and standardized across multiple functions linked to `prepare_request_body` for clarity
PR #593 submitted. It raises a DeprecationWarning when |
ran into my first problem with requests-oauthlib PR candidate as I write some tests It ALWAYS invokes
|
Thanks for running into this.
|
Thanks. Just to clarify two things, and please feel free to talk to me like I'm five. I want to ensure I get this and the tests right:
Unless they are explicitly specified they should not be present, correct?
Please forgive me being verbose and obsessing over these little details. I just want to make sure j get the right behavior and can write tests that ensure we don't get another regression. |
@jvanasco, I can tell about the OAuth2 RFC, however I'm not sure how the
Correct.
It is my understanding, however it will be good to collate with the reality of the field; i.e. requests-oauthlib and differents public providers experiences. Multiple requests-oauthlib discussions requests/requests-oauthlib#218, requests/requests-oauthlib#211, requests/requests-oauthlib#264, already happened. I believe they had a confusion between Poke @Lukasa, @chaosct, @ibuchanan which participated in the requests-oauthlib's discussions. |
Great! thanks so much. I thought that was what is going on but wanted to confirm. I think I know how I want to structure the requests stuff now. I have a handful of commits on the main requests project, so I know what the maintainers like to see in PRs and functionality. |
Yes, to the first part: only a certain type of grant requires them. But on the 2nd part about sending them in the request body, the spec says:
But for servers, it reads:
A compliant client, would not send the credentials in the request body. I believe @JonathanHuot is correct about the 2nd point. |
Hi @ibuchanan, the quotes you are referring to are using the term The roles are clearly explained here rfc6749#1.1 . So, by reading the RFC with those roles mean that a compliant client SHOULD send client credentials ( |
Some server reject the request (400) if the client_id is in the request
body. I think the default should be what is recommended by the spec.
|
Ok. I think the current PR for in terms of
A question I have for @JonathanHuot and @ibuchanan :
To me, it makes sense to extend the Client with storing the |
I've slightly changed the PR for oauthlib (#593) to standardize the test variables for username/password and client_id/client_secret. i think that should prevent mistakes from confusion between the two in the future. The proposed change for requests-oauthlib : requests/requests-oauthlib@master...jvanasco:fix-oauthlib_client_id This one is a bit more drastic, because looking at the code and tests, it seems the library was just trying to make all sorts of things work that shouldn't. The fix does a few things:
So in requests-oauthlib version:
or stated otherwise:
|
@jvanasco : looks very good on oauthlib and requests-oauthlib side. About your 3. question: You can have public clients without client_secret (or empty, that's close on a point of view of the RFC); so the python API must support "no secret". The real-world use-case is often for native applications where you prefer to use authorization code, but you cannot guarantee the security around keep the secret safe, so, either you accept a |
thanks. i'll add some test cases to ensure we can submit |
@JonathanHuot the existing implementation does not support sending an empty string for Supporting it can be adding something like this right after that routine:
That would send an empty string for I think it is worth supporting this, because if the RFC supports either of the two variants... there are likely to be many broken implementations that only support one variant. |
PR for #585, `client_id` behavior with `prepare_request_body`
This original issue is fixed in oauthlib. However the behavior is still there until requests/requests-oauthlib#331 is fixed. |
I found a regression in master when used with requests/requests-oauthlib since #495 has been merged. It's related to authorization grant/web application only.
Basic usage of requests-oauthlib is :
However, since the changes,
client_id
of the session is ignored. I think #505 fixed an use-case but broke another one. We should find a win-win solution.requests-oauthlib code call at https://github.com/requests/requests-oauthlib/blob/master/requests_oauthlib/oauth2_session.py#L196-L198 and oauthlib issue here
https://github.com/oauthlib/oauthlib/blame/master/oauthlib/oauth2/rfc6749/clients/web_application.py#L128.
The text was updated successfully, but these errors were encountered: