Created
April 10, 2019 06:26
-
-
Save rvvvt/a8ef51edbdbb19dc02d0da969775e579 to your computer and use it in GitHub Desktop.
Linkedin Login
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
STEPS: | |
1.- Create an app: | |
in linkedin: https://www.linkedin.com/developers/apps | |
2.- Create your linkedin login URL: | |
Fill the following URL with your developer information: https://www.linkedin.com/oauth/v2/authorization | |
example with response_type, client_id, redirect_uri, state: | |
https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=86zig0sfofozk1&redirect_uri=https://localhost:8443/pro&state=aRandomString | |
3.- Get the user code from linkedin: | |
redict the user to this URL, after the user completes the linkedin login, | |
is going to be redirect to the `redirect_uri` URL you defined in the URL | |
(this URL have to match with any of the ones you have in your linkedin developer account in `Redirect URLs`). | |
the redirect URL is going to have a code= from linkedin like this: | |
https://localhost:8443/pro?code=AQRM1TNl6EFx7Y4KuqRvRcmI7Y2PS0qMHX_AKeFoIxKbho0NLhB3D-1KSyINsgur9WvM_mufdsnkpkOXeNZQwYz2Ww05JRGH6q-rRKjISFt-Qk_sHhjn7L8gDBVaBcZVD27-Z4D-Rz-1bq96jq3Q0tQHKvAF_DNxwXB6439_UQvjCvtGkRNZZCasugdayQ&state=aRandomString | |
copy this code. | |
4.- Get the user token from linkedin: | |
In orther to get the user token you need to make a POST request with the folling information | |
as Params client_id, client_secret, grant_type, redirect_uri, code | |
like this: | |
https://www.linkedin.com/oauth/v2/accessToken?client_id=86zig0sfofozk1&client_secret=N80cs7CMtQPgNCmV&grant_type=authorization_code&redirect_uri=https://localhost:8443/pro&code=AQQud3mML44FbdYgDZpiDGqlNZNpK1pXgJ7LPBaECvcNjfV33kPRUTD2eU_Gk1LJB2KKCcQRuAvPChvy8ibC8L_PaELJLOFJBF7Grt-CUtZxwIOFrvy7OOXtvO2swuAr3OkZyYyGtQ9c1tnE2vgaa07XCTm_2rvLhFUaiFLUToxr79tM1twXuzxWQNPgOw | |
and in the Headers of the POST request this: Content-Type: "application/x-www-form-urlencoded" | |
Linken is going to response with a `access_token` | |
5.- Use the access token to get the user information: | |
Make a GET request to: https://api.linkedin.com/v1/people/~:(first-name) | |
Note that you can ask for more things not only the first name. | |
In the Headers: Authorization: Bearer AQUUcZlT5YwBBpZzq0xyctUR1k8tyENmdX5_kJBd1YiqlJaZAGk38dcLBF8N2Bi2YnprQA-mi8z-br22BqjOsQbljGTi5TqH9K6ZDHl9UjHl2QVziLMq9o9GOaP-WbwXZT6lAXjYbwEHHfQmB6r0Bq27SdeOuqsHSEykrTyTtLNfV7EgVcEhGTSTXVEr9iyJkzVH9fvx_I9hZvuFyLxi-rT1ssRwp_uWe3IBcSueGJHb0x7JAI2As3Q2PP2WIEldAEGWv1JzokLkTr1G2GJAzL-6AQOjWrRa2gU0ghga3aJWFGjdvQCDDHS3oa7ETNDpuei8PwuOfau0f68PzV9zoE_i2Q21rQ | |
Add the token in the Authorization headers as a Bearer. | |
LINKS: | |
https://medium.com/@ellesmuse/how-to-get-a-linkedin-access-token-a53f9b62f0ce | |
https://www.linkedin.com/developers/ | |
https://developer.linkedin.com/docs/signin-with-linkedin# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment