Pages

Saturday, May 23, 2015

Learning oauth2 with linkedin using python script

Today, we are going to learn oauth2 with linkedin using python. It's a very simple and easy task. Let's install the necessary library dependency. In debian, you just will need to install these two dependency packages, that is python-requests-oauthlib and python-oauthlib.

If you want to be sure the module are installed, you can start a python interactive shell, read below:

There are basically two variable value you need to change, client_id and client_secret. You should be able to find these two variable in your linkedin developer application page. Once you login to your developer login page, you should be able to locate these two parameters. Note that, because of privacy of credential, I have remove them all, but you should get be able to find out. Note also you need to provide a redirect url, as seen here, it is http://127.0.0.1 match with what it is found in the script.

So you should copy the first link in the script output into the browser, a linkedin authorization page will be loaded, you should authorized it and the next url, copy and paste back into the terminal. Voila, you can use the token to start use various linkedin api.