illmill 87 Posted July 4, 2013 Report Share Posted July 4, 2013 Okay, I'm trying to get familiar with the Linkedin API and I can't seem to get anything working. It's frustrating because I had a few api functions working, but now nothing is working. I'm able to authenticate and get my access token no problem: http://developer.linkedin.com/documents/authentication After that, my access token doesn't seem to work with anything. Here is a sample access token I generated: AQXPpSvnNU7Q7CsTWBoBznvIvho2ElkohT7KObnOB3LDC63J8TKWWBFnslX96Rl6kFSxDrhTntIxCq-fCnAmW6puUmWp84gZE7ycoG0o_m3FyNBD3qB95oKHqpqWMbz0corcoVfv1-HGmCfKN9-5KsKYwMTkZC3oVXNNYtdFAT6moH-ZYpA Whenever I try to do anything with the linkedin api after I have the access token I get this message: "The remote server returned an error: (401) Unauthorized." This didn't seem to help me at all: http://developer.linkedin.com/documents/error-codes It's frustrating because I had a few of the api functions working before (ie. I was able to GET my own profile info, but I wasn't able to GET other profiles' info, see http://developer.linkedin.com/documents/profile-api), but now this isn't working. The only thing I remember changing was on my page where I see the details for my approved linkedin application is that I clicked "Revoke" under Oauth Token (after I read on their forum that someone was getting a 400 error and revoking the token fixed the issue because that didn't match to the other token he was generating, or something like that, but he was calling the api using javascript - i'm not sure if that matters). Here are a couple of example codes that are giving me the 401 error (if you look at the linkedin api any of the examples they give you are giving me this error): set(#profile get, $plugin function("HTTP post.dll", "$http get", "http://api.linkedin.com/v1/people/~?oauth2_access_token={#access token}", "", "", "", ""), "Global") load html(#profile get) set(#search get, $plugin function("HTTP post.dll", "$http get", "http://api.linkedin.com/v1/people-search?oauth2_access_token={#access token}", "", "", "", ""), "Global") load html(#search get) wait(10) You may refer to http://developer.linkedin.com/documents/profile-api and http://developer.linkedin.com/documents/people-search-api.For the stuff on authentication: http://developer.linkedin.com/documents/authentication I'll try to generate a new oauth token and key on my application, but I was having these issues before that, so I think that won't fix anything. Is it possible that the http POST and GET functions are doing something to encode or decode the string without my knowledge? Quote Link to post Share on other sites
Kev 69 Posted July 4, 2013 Report Share Posted July 4, 2013 Hi Eric,This code will require you to log in and authorise your session. It then grabs your token (via Regex). Feel free to edit it as much as you like. clear cookies ui text box("Email:", #emaillogin) ui text box("Password:", #password) navigate("https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=dfpfagxj5mry&state=SJDRRRRHRHFFFFII&redirect_uri=http://google.ie", "Wait") wait for element(<email field>, "", "Appear") type text(<email field>, #emaillogin, "Standard") type text(<password field>, #password, "Standard") click(<name="authorize">, "Left Click", "No") wait for browser event("Page Loaded", "") set(#token, $url, "Global") set(#token, $replace(#token, "http://www.google.ie/?code=", ""), "Global") set(#token, $find regular expression(#token, ".+(?=\\&state)"), "Global") plugin command("HTTP post.dll", "HTTP POST", "https://www.linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code&code={#token}&redirect_uri=http://google.ie&client_id=dfpfagxj5mry&client_secret=PDMZFKYIsOR9OCLP", "", "", "", #output) { } set(#accesstoken, $find regular expression(#output, "(?<=\\\"\\:\\\").+(?=\\\"\\\})"), "Global") set(#newconnections, $plugin function("HTTP post.dll", "$http get", "https://api.linkedin.com/v1/people/~/connections?modified=new&modified-since=1267401600000/~?oauth2_access_token={#accesstoken}", "", "", "", ""), "Global") set(#connections, $plugin function("HTTP post.dll", "$http get", "https://api.linkedin.com/v1/people/~?oauth2_access_token={#accesstoken}", "", "", "", ""), "Global") 1 Quote Link to post Share on other sites
Aymen 385 Posted July 4, 2013 Report Share Posted July 4, 2013 there is different kinds of tokens , there is access tokens for applications , and there is user tokens to users accessing linkedin from third party applications !to get the user access token you need to first log in to linkedin , then send oauth request ! PS:(i'm working on a function to integrate oauth 2.0 , so you can integrate this kind of APIs easily without headaches) Quote Link to post Share on other sites
illmill 87 Posted July 4, 2013 Author Report Share Posted July 4, 2013 PS:(i'm working on a function to integrate oauth 2.0 , so you can integrate this kind of APIs easily without headaches)Wow, that sounds awesome! Another thing I wasn't sure about, but haven't even attempted yet, is on some of the linkedin POST stuff it tells you to send in xml format??? How do we do this? Is it possible with the http post plugin? This is what I'm talking about: http://developer.linkedin.com/documents/messaging-between-connections-api Example Messaging XML POST BodyIn this example, we are sending a message to the sender as well as a single connection.<?xml version='1.0' encoding='UTF-8'?><mailbox-item><recipients><recipient><person path='/people/~'/></recipient><recipient><person path="/people/abcdefg" /></recipient></recipients><subject>Congratulations on your new position.</subject><body>You're certainly the best person for the job!</body></mailbox-item> Quote Link to post Share on other sites
Aymen 385 Posted July 4, 2013 Report Share Posted July 4, 2013 Wow, that sounds awesome! Another thing I wasn't sure about, but haven't even attempted yet, is on some of the linkedin POST stuff it tells you to send in xml format??? How do we do this? Is it possible with the http post plugin? This is what I'm talking about: http://developer.linkedin.com/documents/messaging-between-connections-api Example Messaging XML POST BodyIn this example, we are sending a message to the sender as well as a single connection.<?xml version='1.0' encoding='UTF-8'?><mailbox-item><recipients><recipient><person path='/people/~'/></recipient><recipient><person path="/people/abcdefg" /></recipient></recipients><subject>Congratulations on your new position.</subject><body>You're certainly the best person for the job!</body></mailbox-item> use the soap request function Quote Link to post Share on other sites
illmill 87 Posted July 5, 2013 Author Report Share Posted July 5, 2013 use the soap request functionCool, thanks. I'm not familiar with soap requests. How does this work with your plugin? What do I need to enter under "Action"? Do I also need to use $API or can I use this instead of soap request? Here is what I tried and it resulted in nothing (no error, just nothing on the output): <mailbox-item> <recipients> <recipient> <person path=\"/people/email=email@domain.com\"> <first-name>John</first-name> <last-name>Doe</last-name> </person> </recipient> </recipients> <subject>Invitation to Connect</subject> <body>I\'m testing out a new way to connect with people.</body> <item-content> <invitation-request> <connect-type>friend</connect-type> </invitation-request> </item-content> </mailbox-item>", "Global") set(#invitationoutput, $plugin function("HTTP post.dll", "$soap request", "http://api.linkedin.com/v1/people/~/mailbox", #invite xml content), "Global") } Quote Link to post Share on other sites
whoami 26 Posted March 9, 2014 Report Share Posted March 9, 2014 there is different kinds of tokens , there is access tokens for applications , and there is user tokens to users accessing linkedin from third party applications !to get the user access token you need to first log in to linkedin , then send oauth request ! PS:(i'm working on a function to integrate oauth 2.0 , so you can integrate this kind of APIs easily without headaches) Hey Aymen, any updates about this? It will be really useful. Quote Link to post Share on other sites
Bot-Factory 602 Posted March 31, 2014 Report Share Posted March 31, 2014 there is different kinds of tokens , there is access tokens for applications , and there is user tokens to users accessing linkedin from third party applications !to get the user access token you need to first log in to linkedin , then send oauth request ! PS:(i'm working on a function to integrate oauth 2.0 , so you can integrate this kind of APIs easily without headaches) Absolutely second that. Dan Quote Link to post Share on other sites
vonnch 1 Posted April 5, 2014 Report Share Posted April 5, 2014 Count me in here too.I hope to see this API at some point in the future. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.