nvh95 / react-linkedin-login-oauth2

Easily get Authorization Code from Linked In to log in without redirecting.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to exchange Authorization Code with Access Token

patotoma opened this issue · comments

I'm trying to implement Linkedin Oauth2 according to this: https://developer.linkedin.com/docs/oauth2.

What I receive using this component onSuccess hook is Authorization Code but I need to exchange it with Access Token and then send the token to my server.

Making another POST: https://www.linkedin.com/oauth/v2/accessToken is returning CORS error:

Failed to load https://www.linkedin.com/oauth/v2/accessToken: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.

Thank you.

Hey @patotoma
Are you sure that you add your redirect_uri to your app setting
image
In addition, I don't think that you should put the Client Secret in your React App. I think you should send the Authorization Code to server and let your server exchange the Access Token for you
Let me know if you have any question.

@nvh95 exchanging code with token worked from the server side, thanks.