8

I'm using OAuth 1.0a for LinkedIn API. Currently, I've already implemented some calls for getting the profile and connections and they all seem to work fine. But for sending a message, the oauth library throws an exception with the following:

{
  "errorCode": 0,
  "message": "Unknown authentication scheme",
  "requestId": "I2Y0MFJ8ME",
  "status": 401,
  "timestamp": 1378376573339
}

I'm using PHP PECL OAuth. I'm initializing the $oauth object like this:

$oauth = new OAuth(API_KEY, API_SECRET, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_FORM);
$oauth->setToken(ACCESS_TOKEN, SECRET);

and making the rest call like this:

$url = 'https://api.linkedin.com/v1/people/~/mailbox?format=json';
$content_type = array('Content-Type' => 'application/json');
$oauth->fetch($url, $message, OAUTH_HTTP_METHOD_POST, $content_type);

and $message looks something like this:

$message = Array
(
    [recipients] => Array
        (
            [0] => z2222117O
        )

    [subject] => this is my title
    [body] => this is my body
    [format] => json
    [id] => EAS123123
)

It doesn't look like there's anything wrong with the request. I've followed the instructions from the LinkedIn messaging docs. Anyone else had the same problem? Thanks in advance.

Francois Bourgeois
  • 3,650
  • 5
  • 30
  • 41
gerky
  • 6,267
  • 11
  • 55
  • 82

3 Answers3

3

I have answer the question on the below link, seems the same error. Though it seems different technology, but solution would be same to send the access_token in request back to get the protected resources.

The link for your reference. Apache Oltu Linkedin Integration example

Community
  • 1
  • 1
PAA
  • 1
  • 46
  • 174
  • 282
1

LinkedIn requires you to either set the access token in the header or as a query param with the non-standard name of oauth2_access_token. When I sent it as a query param with the name access_token, I got the error you did.

Kyle Heironimus
  • 7,741
  • 7
  • 39
  • 51
0

Some questions on the LinkedIn forums seem to indicate that the error you're getting means that you don't have a valid authentication token.

Are you sure you're sending a correct and active auth token with your message?

Collin Grady
  • 2,226
  • 1
  • 14
  • 14
  • 1
    Yes, I've double checked the token and it's still valid. And it also works for other API requests (get profile, share on wall, etc). – gerky Sep 16 '13 at 13:50