Skip to content
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

client_id from session not used in fetch_token #330

Closed
jvanasco opened this issue Sep 11, 2018 · 1 comment
Closed

client_id from session not used in fetch_token #330

jvanasco opened this issue Sep 11, 2018 · 1 comment

Comments

@jvanasco
Copy link
Contributor

I got tripped up with the example doc on using fetch_token from the overview

https://requests-oauthlib.readthedocs.io/en/latest/

github = OAuth2Session(client_id, state=session['oauth_state'])
token = github.fetch_token(token_url, client_secret=client_secret,
                           authorization_response=request.url)

This doesn't seem to work against custom servers that require a client_id. The logic in fetch_token doesn't pull the client_id off the session, and consequently it's not sent upstream:

https://github.com/requests/requests-oauthlib/blob/master/requests_oauthlib/oauth2_session.py#L200

it looks like we can just add 2 lines as a fallback condition to pull the client_id out:

     client_id = kwargs.get('client_id', '')
+    if not client_id and isinstance(self._client, WebApplicationClient):
+        client_id = self._client.client_id
@jvanasco
Copy link
Contributor Author

This is tied to a regression in oauthlib. I have a PR there and will create a new ticket or reopen this one when that is merged and I can write a PR for this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant