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

InvalidClientIdError in fetch_token() #358

Open
kination opened this issue Jan 15, 2019 · 5 comments
Open

InvalidClientIdError in fetch_token() #358

kination opened this issue Jan 15, 2019 · 5 comments

Comments

@kination
Copy link

Hello,
I faced an error when go on fetch_token() with received url with code and state:

127.0.0.1 - - [15/Jan/2019 16:41:02] "GET /oauth2?code=SOME-CODE-DATA&state=SOME-STATE-DATA HTTP/1.1" 500 -
Traceback (most recent call last):
...
...
oauthlib.oauth2.rfc6749.errors.InvalidClientIdError: (invalid_request) The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed

Is this known issue? Seems something is being fixed in fetch_token in #331 .
If this is not fixed, is there a workaround?

Thanks.

@singingwolfboy
Copy link
Member

@djKooks Can you please provide a reproducible test case?

@kination
Copy link
Author

@singingwolfboy thanks.
I'm working on flask app, and auth server is custom one(implemented in golang):

...
app = Flask(__name__)

@app.route('/')
def main():
	scopes = ['all']
	auth_session = OAuth2Session(CLIENT_ID, redirect_uri=REDIRECT_URL)
	authorization_url, state = auth_session.authorization_url(AUTH_SERVER_AUTHORIZE)
	session['oauth_state'] = state
	return redirect(authorization_url)
	
@app.route('/oauth2')
def callback():
	auth_session = OAuth2Session(CLIENT_ID, state=session['oauth_state'])
	token = auth_session.fetch_token(AUTH_SERVER_TOKEN,
							client_secret=CLIENT_SECRET,
							authorization_response=request.url
	)
...

Callback come with code and state, like http:https://localhost:5555/oauth2?code=PQ9DKLB1MSIYUVMGC2HXWG&state=b0rDHjr9XOwUFw44af2gSGG8aBiTDe. Error above comes on auth_session.fetch_token().

Could you find something?

@holsaeter
Copy link

@djKooks Try passing in include_client_id = True to your auth_session.fetch_token() call. I was having a similair issue arise after updating from 1.1.0 and 1.2.0 because this newly added parameter and passing that in fixed it (although mine was an InvalidClientError)

@dmcgee
Copy link

dmcgee commented Oct 31, 2019

@holsaeter I can confirm that that worked in my case, thanks. (LegacyApplicationClient fetching a token from Microsoft Azure)

@singingwolfboy, do you know whether something needs to be done to force an update on readthedocs.io? https://requests-oauthlib.readthedocs.io/en/latest/api.html doesn't reflect the current state of the project and omits the include_client_id parameter to fetch_token(). That parameter is documented in the commit that added it, though, so it appears that Read the Docs is behind.

@jtroussard
Copy link
Contributor

jtroussard commented Jul 21, 2020

@singingwolfboy Sorry to be bringing this old stuff back to life. Found some free time and wanted to cherry pick a few of these issues to clean up. Seems to me that this issue is settled, however, ReadTheDocs is in fact behind. Pulled down the repo, ran make html in docs, thinking that would update the html files, then I noticed that these are ignored files? .gitignore line 9. Anyways I figured you might know how to refresh/rebuild the docs.

[EDIT]

Continued reading and found this issue addressing a similar out of sync docs issue: #392 Read the Docs is out of sync. and it looks like that the project needs push out a release to rebuild the documentation. Is there any desire to push a general release update just to get the project on level footing again? If anything get the documentation more current?

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

5 participants