如何正确访问Mendeley API?我无法获取文件的document_id

时间:2019-07-08 17:38:41

标签: python api mendeley

如何访问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

lib应该是词典列表。 根据文档,它应包含有关“ document_id”的信息。 (https://dev.mendeley.com/methods/#files) 如果我尝试包含document_id,则结果为空。

0 个答案:

没有答案