我有一个mendeley帐户,我正在使用他们的在线版本。我创建了一个用户I和客户端密码,将其保存在的config.yml文件中,并使用它进行身份验证。我正在使用their website上提供的以下代码
import yaml
from mendeley import Mendeley
with open('config.yml') as f:
config = yaml.load(f)
REDIRECT_URI = 'http://localhost:5000/oauth'
mendeley = Mendeley(config['clientId'], config['clientSecret'], REDIRECT_URI)
auth = mendeley.start_client_credentials_flow()
session = auth.authenticate()这段代码运行得很好,而且我没有得到错误。但是当我试图使用example中的命令访问数据时,它抛出了错误。例如
>> print (session.profiles.me.display_name)
mendeley.exception.MendeleyApiException: The Mendeley API returned an error (status: 400, message: No userid found in auth token)
>> for document in session.documents.iter():
print document.title
mendeley.exception.MendeleyApiException: The Mendeley API returned an error (status: 403, message: Access to this document is not allowed)我被困在这里,不知道如何从mendeley的API访问我在mendeley上的数据或文章。任何帮助都将受到高度的感谢。
发布于 2018-02-24 08:08:12
您正在使用客户端凭据流(来自OAuth的术语)。引用the docs
此流程不需要用户登录。但是,它只提供对有限资源集(众包文档的只读Mendeley Catalog )的访问。
您的问题中的两个调用是私有(用户)信息,因此将失败。
另一方面,下面的方法应该是可行的:
print session.catalog.by_identifier(doi='10.1371/journal.pmed.0020124', view='stats').reader_count如果您要访问私人信息,则需要用户登录。This question应该能帮上忙。
https://stackoverflow.com/questions/47673713
复制相似问题