1

How can I access mendeley API? (files.document_id)

from mendeley import Mendeley
import requests

# I've changed the authentication details of my script (of course)
client_id = ****
client_secret = "**************"
redirect_uri = "********************"

mendeley = Mendeley(client_id, redirect_uri=redirect_uri)

auth = mendeley.start_implicit_grant_flow()

login_url = auth.get_login_url()

res = requests.post(login_url, allow_redirects=False, data={
    'username': '**********',
    'password': '**********'
})

auth_response = res.headers['Location']

session = auth.authenticate(auth_response)

lib = []
for f in session.files.iter():
    try:
        dic = {}
        dic['filehash'] = f.filehash
        dic['mime_type'] = f.mime_type
        dic['file_name'] = f.file_name
        dic['id'] = f.id
        dic['size'] = f.size
        dic['document_id'] = f.document_id  # I can't access this one.
        lib.append(dic)
    except:
        pass

The lib should be a list of dictionaries. It should contain information about 'document_id' according to documentation. (https://dev.mendeley.com/methods/#files) If I try to include document_id the result is empty.

cezar
  • 11,616
  • 6
  • 48
  • 84
TheEd0315
  • 13
  • 4

0 Answers0