JeffersonFilho / react-linkedin-sdk

MIT License
28 stars 11 forks source link

linkedIn accessToken #8

Open carloska opened 6 years ago

carloska commented 6 years ago

I want to ask if there is any way to ask for linkedIn access token with help of this component? My login procedure should be in this way:

  1. LinkedIn authentication fired from frontend, where I get an accessToken
  2. The accessToken will be send to backend to login
  3. At the backend side, get informations from linkedIn with accessToken, and resolve login
  4. return the login result to frontend

This procedure is implemented at Facebook login, the same way I want also at LinkedIn

thanks a lot.

JeffersonFilho commented 6 years ago

I will have a look into this and get back to you. I think is possible to do and if it is I will implement into the component 👍

carloska commented 6 years ago

I will have a look into this and get back to you. I think is possible to do and if it is I will implement into the component 👍

I found a possible way: Im getting an access token from window.IN.ENV.auth.oauth_token I put this token into response and send it back to callback, from there send is back to backend, and the LinkedIn rest api worked with access token attached to url as parameter "oauth_token". I dont know if is this a good way, but it`s working, and the token expires after a time.

It would be also a good improvement the ability to define the complete render node instead of the default. For example if I want to use a link instead of a button, or I want to use my component button, with a logo inside, or something else. For example at my facebook component: render={renderProps => (

            )}
nvh95 commented 6 years ago

@carloska I recently worked with Linked In sign in feature. I did consider your solution before (send oauth_token from window.IN.ENV.auth.oauth_token to server, and server validate one more time) but it is not documented anywhere, so I can not know they will support it in the future. So I solved this problem by following this link Authenticating with OAuth 2.0. I did wrapped it into a package. If you are still interested, take a look at my repo https://github.com/nvh95/react-linkedin-login-oauth2

JeffersonFilho commented 6 years ago

@carloska Awesome, I like the idea of a custom component! I will see if I implement this option this week with the oauth_token included too.

nitucassian commented 6 years ago

I am also trying to get the access token. but I get: Cannot read property 'isAuthorized' of undefined seems that handleAuthorization = e => { if (window.IN.User.isAuthorized()) { return window.IN.User.logout(this.callBack, '') } return window.IN.User.authorize(this.callBack, '') } is where this happens

JeffersonFilho commented 6 years ago

I will have a look to do and let you know what I get.