mua*_*aiz 5 python oauth mendeley
我从这里读Mendeley文档.我试图在我的控制台中获取数据,我正在使用教程中的以下代码
from mendeley import Mendeley
# These values should match the ones supplied when registering your application.
mendeley = Mendeley(client_id, redirect_uri=redirect_uri)
auth = mendeley.start_implicit_grant_flow()
# The user needs to visit this URL, and log in to Mendeley.
login_url = auth.get_login_url()
# After logging in, the user will be redirected to a URL, auth_response.
session = auth.authenticate(auth_response)
Run Code Online (Sandbox Code Playgroud)
现在我不明白auth_response
最后一行代码会从哪里来?有人有任何想法吗?谢谢
我能够使用以下代码进行实验并使其工作,完全自动化.没有用户干预
client_id = 1
client_secret = "XXXXXXXXX"
redirect_uri = "http://localhost:8080/testing"
from mendeley import Mendeley
# These values should match the ones supplied when registering your application.
mendeley = Mendeley(client_id, redirect_uri=redirect_uri)
auth = mendeley.start_implicit_grant_flow()
# The user needs to visit this URL, and log in to Mendeley.
login_url = auth.get_login_url()
import requests
res = requests.post(login_url, allow_redirects = False, data = {
'username': 'xxxx@gmail.com',
'password': 'xxxxx'
})
auth_response = res.headers['Location']
# After logging in, the user will be redirected to a URL, auth_response.
session = auth.authenticate(auth_response)
print(session.files.list().items)
Run Code Online (Sandbox Code Playgroud)
最后一行打印[<mendeley.models.files.File object at 0x1115b5400>]
表示访问是否有效
归档时间: |
|
查看次数: |
202 次 |
最近记录: |