0

I'm trying to authorize against the Mendeley API using the Client credentials authorization flow as described in the official documentation.

However, when I try:

curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -u 799:1K2757WBBkLr9DOs -d "grant_type=client_credentials&scope=all" https://api.mendeley.com/oauth/token

I get this response:

{"message":"Credentials are required to access this resource."}

Trying out the other option:

curl -X POST -H "Content-Type: application/x-www-form-urlencoded" "https://api.mendeley.com/oauth/token?grant_type=client_credentials&scope=all&client_id=799&client_secret=1K2757WBBkLr9DOs"

makes no difference.

cezar
  • 11,616
  • 6
  • 48
  • 84
  • you probably shouldn't share your credentials like this... but personally it works with my credentials, are you sure the client_id is 799? mine is 4 integers, maybe double-check client_id/client_secret first – Guillaume Mar 30 '21 at 09:05
  • @Guillaume Those are not my real credentials. They are taken from the official documentation. Please check the link at the beginning of the question. On my machine I use my real client ID, which is 4 digits, and the real client secret. – cezar Mar 30 '21 at 10:03
  • ok have you tried using Postman? or even with simple JavaScript which I just tested and works too: ```fetch('https://api.mendeley.com/oauth/token', {method: 'POST', headers: {'Content-Type': 'application/x-www-form-urlencoded',Authorization: `Basic ${btoa(`${clientId}:${clientSecret}`)}`},body: 'grant_type=client_credentials&scope=all'}).then(response => response.json()).then(console.log);``` – Guillaume Mar 31 '21 at 11:37
  • @Guillaume thanks for your help, but I tried Postman before, I tried now with your JS example, before tried wtih PHP Guzzle. Everything gives me the same response. There must be an issue with the client ID or the client secret, I suppose. – cezar Mar 31 '21 at 12:04
  • 1
    yes I suggest you contact them over [here](https://service.elsevier.com/app/chat/chat_launch/supporthub/mendeley/p/16075/) so they can sort your problem – Guillaume Mar 31 '21 at 12:12
  • @Guillaume Thank you for your help. I'm just plain stupid. In the section "My Apps" I clicked on "Generate secret" and copied the value and tried so many times. But I forgot to click "Update". After that it worked well. Mea culpa! – cezar Mar 31 '21 at 17:29
  • @cezar: You can add that as an answer. I made the same mistake. – s.ouchene Sep 19 '21 at 09:51

0 Answers0