Home > Net >  omniauth: (linkedin) Authentication failure! invalid_credentials
omniauth: (linkedin) Authentication failure! invalid_credentials

Time:01-05

Request phase initiated. Started GET "/users/auth/linkedin/callback?code=...&state=..." for 127.0.0.1 at 2022-09-14 20:50:20 0200 D, [2022-09-14T20:50:20.537126 #37240] DEBUG -- omniauth: (linkedin) Callback phase initiated. E, [2022-09-14T20:50:21.021252 #37240] ERROR -- omniauth: (linkedin) Authentication failure! invalid_credentials: OAuth2::Error, invalid_request: A required parameter "client_secret" is missing {"error":"invalid_request","error_description":"A required parameter \"client_secret\" is missing"} Processing by Users::OmniauthCallbacksController#failure as HTML

ruby version 3.2.0 rails version 7.0.4

gem 'omniauth' gem 'omniauth-linkedin-oauth2'

CodePudding user response:

I can confirm that your fix does indeed work. Thank you! I'm adding it to my app to the config/initializers.rb as

 module OmniAuth
  module Strategies
    class LinkedIn < OmniAuth::Strategies::OAuth2
      def token_params
        super.tap do |params|
          params.client_secret = options.client_secret
        end
      end
    end
  end
end

Add this in your code

lib/strategies/linkedin.rb

And also this code in your devise.rb

require "strategies/linkedin"

  • Related