0

I want to use API from Publons. They mentioned "Any other requests should include a token in the Authorization HTTP header and prefixed with 'Token'. So, i try to set the Token in headers. This is my code


$client = new Client([
            'base_uri' => "https://publons.com/api/v2/academic/",
            'headers' => [
                'Token' => "MyToken"
            ]
        ]);

The result is {"detail":"Authentication credentials were not provided."}. I make sure the token is correct, beacause I've try it on Talend API Tester and works. Can anyone help me? Where is the mistake?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Ilya Trianggela
  • 305
  • 1
  • 9

1 Answers1

1

Just guessing, there's not much in their docs but I suppose it would look like that:

$client = new Client([
            'base_uri' => "https://publons.com/api/v2/academic/",
            'headers' => [
                'Authorization' => "Token{Your api token here}"
            ]
]);

They want authorization header and token prefixed with "Token"...

Also this question would give you more ideas how to deal with your case.

cssBlaster21895
  • 3,670
  • 20
  • 33