1

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 を含めようとすると、結果は空になります。

4

0 に答える 0