Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I store the LinkedIn API AccessToken so I don't have to re-enter credentials every time I use the LinkedIn API?

I am writing an app to mine information from LinkedIn. I've only found one code sample thus far on oAuth. I'm having trouble understanding the workflow of oAuth, for example:

  1. The Example asks for the Username/Password combination to log into LinkedIn and return a token, but in my case, I will always use the same LinkedIn Account.

Since I'm always going to be using the same user to access the LinkedIn API, is there a way to do it so I don't have to re-enter the user name and password for every access request? The facebook API allows me to set the Token to not expire, thereby allowing me to save this token as an Attribute inside my application).

The idea is :

  1. Get a token for a certain LinkedIn Account
  2. Store it in my app hardcoded, since this is the only account I will be using the retrieve information from LinkedIn.
  3. Make API Calls using this token, everytime I need it
  4. Parse the JSON/XML file

How do I do this in C#?

like image 902
Marcello Grechi Lins Avatar asked Dec 12 '11 14:12

Marcello Grechi Lins


2 Answers

You first need to determine the member token, and the corresponding OAuth token -- you could do this as a one off, and LinkedIn have some quite good documentation about authorizing (along with links to tools to verify, and to libraries that you can use to simplyify matters)

Once you have those, it's just a case of storing them "somewhere safe" - there is even a clause in the LinkedIn APIs Terms of Use that permits storage:

You may store the Member Token and the OAuth Token until the earlier of:

  • Your ceasing using the APIs;
  • The LinkedIn user uninstalls your application or directs you to delete the user's information; or,
  • We terminate your use of them for breach of these Terms.
like image 75
Rowland Shaw Avatar answered Nov 06 '22 21:11

Rowland Shaw


Just to be exceptionally clear - what you need to store on your system is the OAuth access token for that member. So you will need to store that token along with the userID (just so you can remember who that token belongs to). That token, along with your API key and secret, should give you the ability to call the linkedin services.

like image 32
TheSteve0 Avatar answered Nov 06 '22 19:11

TheSteve0