decioferreira / omniauth-linkedin-oauth2

A LinkedIn OAuth2 strategy for OmniAuth.
MIT License
117 stars 147 forks source link

Secret is nil #50

Closed dsandstrom closed 5 years ago

dsandstrom commented 5 years ago

I'm trying to upgrade an app to use v2 of LinkedIn's Api. I found this gem, which I hope should replace the omniauth-linkedin gem. I changed the provider method to something like:

provider :linkedin, 'key', 'secret', scope: 'r_liteprofile r_emailaddress w_member_social'

However, after going through the oauth connection process and trying to post as the user I get an error:

LinkedIn::Errors::UnauthorizedError ((401): [unauthorized]. The token used in the OAuth request is not valid.

I believe the cause of this issue is I never obtain a secret for the user, the oauth hash is incompete. After the user accepts connecting an account, the request.env['omniauth.auth'] hash looks something like:

#<OmniAuth::AuthHash credentials=#<OmniAuth::AuthHash expires=true expires_at=1555966761 token="verylongtoken"> extra=#<OmniAuth::AuthHash raw_info=#<OmniAuth::AuthHash firstName=#<OmniAuth::AuthHash localized=#<OmniAuth::AuthHash en_US="me"> preferredLocale=#<OmniAuth::AuthHash country="US" language="en">> id="id" lastName=#<OmniAuth::AuthHash localized=#<OmniAuth::AuthHash en_US="me"> preferredLocale=#<OmniAuth::AuthHash country="US" language="en">>>> info=#<OmniAuth::AuthHash::InfoHash email="me@email.com" first_name="me" last_name="me" picture_url=nil> provider="linkedin" uid="uid">

Notice that there is no secret.

I tried changing the requested permissions. I've looked at the app in LinkedIn and looks to be setup correctly. LinkedIn was working yesterday, but they must have forced v2 on the app today. I tried using different versions of omniauth-oauth2 gem. Please let me know if you have any suggestions. Thanks.

dsandstrom commented 5 years ago

I guess there is no secret in oauth 2.0. So I think my problem is with https://github.com/hexgnu/linkedin .