I was reading Mendeley docs from here. I am trying to get data in my console for which I am using the following code from the tutorial
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)
Now I don't understand where is auth_response
will come from in the last line of code ? Does anybody have any idea ? Thanks
I was able to experiment with and get it working using below code, fully automated. No user intervention
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': '[email protected]',
'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)
The last line prints [<mendeley.models.files.File object at 0x1115b5400>]
which means the access if working
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With