LinkedIn API oauth issues with sending message node.js -
i have same issue:
how post linkedin "share" node-auth?
essentially using linkedin-js npm module works great requests. using module in conjuncture passport , generating oauth token , secret. when post did not work messaging went oauth dependency library , changed content-type headers application/json , x-li-format headers json. also, other bases covered. have "w_messages" set in scope , other requests working.
i not need x-li-format header since have application/json header. thing can think of access tokens off (perhaps step missing - unlikely since other requests requiring authentication work) or plaintext signature thrown off application/json content-type (following error not thrown):
if( signaturemethod != "plaintext" && signaturemethod != "hmac-sha1") throw new error("un-supported signature method: " + signaturemethod )
i went error message:
{ statuscode: 401, data: '<?xml version="1.0" encoding="utf-8" standalone="yes"?>\n<error>\n <status>401</status>\n <timestamp>1375876823051</timestamp>\n <request-id>0wfu40uzp8</request-id>\n <error-code>0</error-code>\n <message>[unauthorized]. oau:fgb949d9gb66|427a55ea-a05e-4494-88f5-a33230bd719a|*01|*01:1375876915:wwqvtae9wqneef8ezl6yl7dmyv4=</message>\n</error>\n' }
to error message:
{ statuscode: 401, data: '{\n "errorcode": 0,\n "message": "[unauthorized]. oau:fgb949d9gb66|ce1f124c-1e10-4abc-8777-55bbd9621100|*01|*01:1375913097:eh90q69mhgrwicvcknimzaunlqi=",\n "requestid": "koyhe8k0m6",\n "status": 401,\n "timestamp": 1375913004009\n}' }
here api call , corresponding oauth calls:
linkedinclient.apicall('post', '/people/~/mailbox', { "token": { "oauth_token_secret": tokensecret , "oauth_token": token }, "mailbox-item": {"recipients": { "values": [ { "person": { "_path": people, } }] }, "subject": subject, "body": body} } , function (error, result) { if (result){ req.io.emit('success', {success : "linkedin message sent successfully."}); } console.log(error); } ); var client = { oauth: new oauth( 'https://api.linkedin.com/uas/oauth/requesttoken' , 'https://api.linkedin.com/uas/oauth/accesstoken' , key , secret , '1.0a' , redirect , 'hmac-sha1' , null , {'accept': '*/*', 'connection': 'close', 'x-li-format': 'json', 'content-type': 'application/json'} ) } client.oauth.post( _rest_base + path , token.oauth_token , token.oauth_token_secret , params , 'application/json' , requestcallback(callback) );
Comments
Post a Comment