Mendeley / mendeley-api-python-catalog-example

This is a simple example of an application that consumes the Mendeley API, using the Python SDK.
Apache License 2.0
23 stars 6 forks source link

InvalidClientError following example #1

Closed cdeblois closed 10 years ago

cdeblois commented 10 years ago

I cloned the repo. I created app:

id=1055
key=provided secret here
redirect_uri=http://localhost:5000/oauth

I updated the config.yaml with above key and secret.

I ran the script and got the below.

ubuntu@ip-10-63-175-117:~/mendeley-api-python-catalog-example$ python mendeley-catalog.py
Traceback (most recent call last):
  File "mendeley-catalog.py", line 8, in 
    session = mendeley.start_client_credentials_flow().authenticate()
  File "/usr/local/lib/python2.7/dist-packages/mendeley/auth.py", line 32, in authenticate
    token = self.oauth.fetch_token(token_url, auth=auth, scope=['all'])
  File "/usr/local/lib/python2.7/dist-packages/requests_oauthlib/oauth2_session.py", line 180, in fetch_token
    self._client.parse_request_body_response(r.text, scope=self.scope)
  File "/usr/local/lib/python2.7/dist-packages/oauthlib/oauth2/rfc6749/clients/backend_application.py", line 156, in parse_request_body_response
    self.token = parse_token_response(body, scope=scope)
  File "/usr/local/lib/python2.7/dist-packages/oauthlib/oauth2/rfc6749/parameters.py", line 303, in parse_token_response
    validate_token_parameters(params, scope)
  File "/usr/local/lib/python2.7/dist-packages/oauthlib/oauth2/rfc6749/parameters.py", line 310, in validate_token_parameters
    raise_from_error(params.get('error'), params)
  File "/usr/local/lib/python2.7/dist-packages/oauthlib/oauth2/rfc6749/errors.py", line 239, in raise_from_error
    raise cls(**kwargs)
oauthlib.oauth2.rfc6749.errors.InvalidClientError

Please help.

Thanks

matt-thomson commented 10 years ago

That error usually indicates that your client ID/secret are incorrect. Please could you sign in to the developer portal at http://dev.mendeley.com, generate a new secret (remember to click on the Submit button), update your config.yml and try again?

matt-thomson commented 10 years ago

Actually, this is due to stricter validation introduced in a recent version of oauthlib. I'll fix this for now by enforcing an earlier version of oauthlib, and I'll look into making the API compatible with the newer oauthlib separately.

matt-thomson commented 10 years ago

OK, please could you upgrade to the latest SDK? You can do this by running the following:

git pull
pip install -U -r requirements.txt
cdeblois commented 9 years ago

Seems I get the same error.

@dev1: mendeley-api-python-catalog-example $> python mendeley-catalog.py
Traceback (most recent call last):
  File "mendeley-catalog.py", line 8, in 
    session = mendeley.start_client_credentials_flow().authenticate()
  File "/usr/local/lib/python2.7/dist-packages/mendeley/auth.py", line 32, in authenticate
    token = self.oauth.fetch_token(token_url, auth=auth, scope=['all'])
  File "/usr/local/lib/python2.7/dist-packages/requests_oauthlib-0.4.2-py2.7.egg/requests_oauthlib/oauth2_session.py", line 199, in fetch_token
    self._client.parse_request_body_response(r.text, scope=self.scope)
  File "/usr/local/lib/python2.7/dist-packages/oauthlib/oauth2/rfc6749/clients/backend_application.py", line 156, in parse_request_body_response
    self.token = parse_token_response(body, scope=scope)
  File "/usr/local/lib/python2.7/dist-packages/oauthlib/oauth2/rfc6749/parameters.py", line 303, in parse_token_response
    validate_token_parameters(params, scope)
  File "/usr/local/lib/python2.7/dist-packages/oauthlib/oauth2/rfc6749/parameters.py", line 310, in validate_token_parameters
    raise_from_error(params.get('error'), params)
  File "/usr/local/lib/python2.7/dist-packages/oauthlib/oauth2/rfc6749/errors.py", line 239, in raise_from_error
    raise cls(**kwargs)
oauthlib.oauth2.rfc6749.errors.InvalidClientError
cdeblois commented 9 years ago

The issue was the yaml file and the keys needing to be regenerated.