Radek Simko
Radek Simko

Reputation: 16126

OAuth authorization - Establishing a requestToken

I need to get request token to be able to work with LinkedIn API.

I'm trying to send this request (by POST) to:

https://api.linkedin.com/uas/oauth/requestToken

with those parameters

'oauth_callback' => 'http://www.myserver.com/tokenReturned',
'oauth_consumer_key' => '---',
'oauth_consumer_secret' => '---',
'oauth_nonce' => uniqid(time(), TRUE),
'oauth_signature_method' => 'PLAINTEXT',
'oauth_signature' => '---',
'oauth_timestamp' => time(),
'oauth_version' => '1.0'

Anyway, the LinkedIn server is responding HTTP 100 and this message:

oauth_problem=parameter_absent&oauth_parameters_absent=oauth_consumer_key&oauth_signature_method&oauth_signature&oauth_timestamp&oauth_nonce

What am i doing wrong? Which parameter am i missing?

Or should parameters be send via HTTP Header, not through POST parameters?

Upvotes: 2

Views: 3222

Answers (1)

Johnny Oshika
Johnny Oshika

Reputation: 57482

The parameters should be sent in the "Authorization" HTTP header. For example:

POST https://api.linkedin.com/uas/oauth/requestToken HTTP/1.1
Authorization: OAuth oauth_callback="http%3a%2f%2flocalhost%3a2161%2flogin%2flinkedin", oauth_consumer_key="YOUR_KEY", oauth_nonce="SOME_NOUNCE", oauth_signature="YOUR_SIGNATURE", oauth_signature_method="HMAC-SHA1", oauth_timestamp="YOUR_TIMESTAMP", oauth_version="1.0"
Host: api.linkedin.com
Connection: Keep-Alive

Note a few things:

  • You should never send your oauth consumer secret
  • the callback url needs to be encoded

More info available here: http://developer.linkedin.com/docs/DOC-1245

Upvotes: 1

Related Questions