mendeley / mendeley-api-python-example Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
I am trying to use Folders api to get all folders or all documents in a particular folder. My code is based on the python example and the authorization work with other API calls like list all documents.
session['token'] = mendeley_session.token
folders_req = {}
response = requests.get(url= "https://api.mendeley.com/folders/",json=folders_req)
response_dict = json.loads(response.text)
print (response_dict)
response = requests.get(url= "https://api.mendeley.com/folders/2a6b304b-5b59-493e-a4b6-92fcf065db05",params={
'id': '2a6b304b-5b59-493e-a4b6-92fcf065db05'
})
where '2a6b304b-5b59-493e-a4b6-92fcf065db05' is one of the folders in my library
I get the following response for the two API calls above
{'errorId': 'oauth/NOT_AUTHORIZED', 'message': 'Could not access resource because: No auth header'}
Are these API calls no longer allowed?
Hey folks,
I'm trying to get this example code working, as it is pretty close to something I want to build. I keep getting this error in the oauth package. I installed the packages in requirements.txt
and am running python within a fresh virtualenv. Anyone have any ideas? Here is the stack trace:
Traceback (most recent call last): File
"/home/alice/Code/projects/bibliography_manager/mendeley_python_example/mendeley-api-python-example/test/lib/python2.7/site-packages/flask/app.py",
line 1836, in __call__ return self.wsgi_app(environ, start_response) File
"/home/alice/Code/projects/bibliography_manager/mendeley_python_example/mendeley-api-python-example/test/lib/python2.7/site-packages/flask/app.py",
line 1820, in wsgi_app response = self.make_response(self.handle_exception(e))
File
"/home/alice/Code/projects/bibliography_manager/mendeley_python_example/mendeley-api-python-example/test/lib/python2.7/site-packages/flask/app.py",
line 1403, in handle_exception reraise(exc_type, exc_value, tb) File
"/home/alice/Code/projects/bibliography_manager/mendeley_python_example/mendeley-api-python-example/test/lib/python2.7/site-packages/flask/app.py",
line 1817, in wsgi_app response = self.full_dispatch_request() File
"/home/alice/Code/projects/bibliography_manager/mendeley_python_example/mendeley-api-python-example/test/lib/python2.7/site-packages/flask/app.py",
line 1477, in full_dispatch_request rv = self.handle_user_exception(e) File
"/home/alice/Code/projects/bibliography_manager/mendeley_python_example/mendeley-api-python-example/test/lib/python2.7/site-packages/flask/app.py",
line 1381, in handle_user_exception reraise(exc_type, exc_value, tb) File
"/home/alice/Code/projects/bibliography_manager/mendeley_python_example/mendeley-api-python-example/test/lib/python2.7/site-packages/flask/app.py",
line 1475, in full_dispatch_request rv = self.dispatch_request() File
"/home/alice/Code/projects/bibliography_manager/mendeley_python_example/mendeley-api-python-example/test/lib/python2.7/site-packages/flask/app.py",
line 1461, in dispatch_request return
self.view_functions[rule.endpoint](**req.view_args) File
"/home/alice/Code/projects/bibliography_manager/mendeley_python_example/mendeley-api-python-example/mendeley-example.py",
line 35, in auth_return mendeley_session = auth.authenticate(request.url) File
"/home/alice/Code/projects/bibliography_manager/mendeley_python_example/mendeley-api-python-example/test/lib/python2.7/site-packages/mendeley/auth.py",
line 68, in authenticate scope=['all']) File
"/home/alice/Code/projects/bibliography_manager/mendeley_python_example/mendeley-api-python-example/test/lib/python2.7/site-packages/requests_oauthlib/oauth2_session.py",
line 199, in fetch_token self._client.parse_request_body_response(r.text,
scope=self.scope) File
"/home/alice/Code/projects/bibliography_manager/mendeley_python_example/mendeley-api-python-example/test/lib/python2.7/site-packages/oauthlib/oauth2/rfc6749/clients/base.py",
line 409, in parse_request_body_response self.token =
parse_token_response(body, scope=scope) File
"/home/alice/Code/projects/bibliography_manager/mendeley_python_example/mendeley-api-python-example/test/lib/python2.7/site-packages/oauthlib/oauth2/rfc6749/parameters.py",
line 376, in parse_token_response validate_token_parameters(params) File
"/home/alice/Code/projects/bibliography_manager/mendeley_python_example/mendeley-api-python-example/test/lib/python2.7/site-packages/oauthlib/oauth2/rfc6749/parameters.py",
line 386, in validate_token_parameters raise
MissingTokenError(description="Missing access token parameter.")
MissingTokenError: (missing_token) Missing access token parameter.
Other info: system is an up to date Arch linux install. I got the same error using 2.7 and 3.4.
127.0.0.1 - - [19/Feb/2015 12:50:13] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [19/Feb/2015 12:50:16] "GET /oauth?state=.....&code=..... HTTP/1.1" 500 -
Traceback (most recent call last):
File "/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/..../mendeley-api-python-example/mendeley-example.py", line 33, in auth_return
auth = mendeley.start_authorization_code_flow(state=session['state'])
File "/home/matej/.virtualenvs/mendeley-api-python-example/lib/python2.7/site-packages/werkzeug/local.py", line 368, in <lambda>
__getitem__ = lambda x, i: x._get_current_object()[i]
KeyError: 'state'
My installed modules:
(mendeley-api-python-example) ↪ pip freeze
-f /home/matej/.pip/wheels
Flask==0.10.1
Jinja2==2.7.3
MarkupSafe==0.23
PyYAML==3.11
Werkzeug==0.10
argparse==1.2.1
arrow==0.5.0
certifi==14.05.14
future==0.14.3
itsdangerous==0.24
memoized-property==1.0.2
mendeley==0.3.0
oauthlib==0.7.2
python-dateutil==2.4.0
requests==2.5.1
requests-oauthlib==0.4.2
six==1.9.0
wheel==0.24.0
wsgiref==0.1.2
Please, can you give some hints on how pagination works with Flask.
Using the list method, for instance docs_list = mendeley_session.groups.get('3b7a5bd7-ba7a-36de-a961-f88d113ba523').documents.list(page_size=5)
, I'm not able in figuring out how to manage the object Page to navigate through the other pages
thank you,
francesco
Modified domain only here and this is what i get:
@dev1: mendeley-api-python-example $> sudo python mendeley-example.py * Running on http://dev1.catalyticds.com:5000/ * Restarting with reloader 172.29.255.14 - - [25/Nov/2014 22:02:30] "GET / HTTP/1.1" 500 - Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1836, in __call__ return self.wsgi_app(environ, start_response) File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1820, in wsgi_app response = self.make_response(self.handle_exception(e)) File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1403, in handle_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1479, in full_dispatch_request response = self.process_response(response) File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1693, in process_response self.save_session(ctx.session, response) File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 837, in save_session return self.session_interface.save_session(self, session, response) File "/usr/local/lib/python2.7/dist-packages/flask/sessions.py", line 326, in save_session val = self.get_signing_serializer(app).dumps(dict(session)) File "/usr/local/lib/python2.7/dist-packages/itsdangerous.py", line 566, in dumps rv = self.make_signer(salt).sign(payload) File "/usr/local/lib/python2.7/dist-packages/itsdangerous.py", line 412, in sign return value + sep + self.get_signature(value) File "/usr/local/lib/python2.7/dist-packages/itsdangerous.py", line 347, in get_signature key = self.derive_key() File "/usr/local/lib/python2.7/dist-packages/itsdangerous.py", line 336, in derive_key mac = hmac.new(self.secret_key, digestmod=self.digest_method) File "/usr/lib/python2.7/hmac.py", line 133, in new return HMAC(key, msg, digestmod) File "/usr/lib/python2.7/hmac.py", line 71, in __init__ key = key + chr(0) * (blocksize - len(key)) TypeError: unsupported operand type(s) for +: 'dict' and 'str' 172.29.255.14 - - [25/Nov/2014 22:02:30] "GET /?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 200 - 172.29.255.14 - - [25/Nov/2014 22:02:30] "GET /?__debugger__=yes&cmd=resource&f=jquery.js HTTP/1.1" 200 - 172.29.255.14 - - [25/Nov/2014 22:02:30] "GET /?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1" 200 - 172.29.255.14 - - [25/Nov/2014 22:02:30] "GET /?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 - 172.29.255.14 - - [25/Nov/2014 22:02:31] "GET /?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 - 172.29.255.14 - - [25/Nov/2014 22:02:31] "GET /?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 - 172.29.255.14 - - [25/Nov/2014 22:02:31] "GET /?__debugger__=yes&cmd=resource&f=source.png HTTP/1.1" 200 -
These are the errors I'm getting following the install instructions for this module. I'm running Mint 17.3
Is there a workaround for this?
Hello, Im having troubles using this code. From what can i understand is that I needed to change all the "collections" modules for "collections.abc" and it seems to be working the last thing i dont understand is how to use the yaml module. My understanding of this issue is the yaml module got updated and i need to add some parameters (here is the article which i consulted: https://stackoverflow.com/questions/69564817/typeerror-load-missing-1-required-positional-argument-loader-in-google-col) but im not sure im doing this correctly, because when i run the code the following apears in my screen (NOTE: I'm using a virtual enviroment):
This is the code:
from flask import Flask, redirect, render_template, request, session
import yaml
from mendeley import Mendeley
from mendeley.session import MendeleySession
with open('config.yml') as f:
config = yaml.safe_load(f)
REDIRECT_URI = 'http://localhost:5000/oauth'
This is the result:
(venvMendeley) C:\Users\rafae\Downloads\mendeley-api-python-example-master\mendeley-api-python-example-master>python mendeley-example.py
* Serving Flask app 'mendeley-example'
* Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:5000/
Press CTRL+C to quit
* Restarting with stat
* Debugger is active!
* Debugger PIN: 996-554-940
I am searching for a specific citation style. And I don't know where to start.
My professor asked for the entery in bibilography to look like.
Example bibliography:
So first name abbreviation and after surname. Everything I check is vice versa so first surname and after its name abbreviation. I ask you kindly for help.
Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.