0
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'
Holger Just
  • 52,918
  • 14
  • 115
  • 123

3 Answers3

1

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"

  • 1
    Hi there! I have the same problem But unfortunately this solution didn't help me. Now I've hot another Error: `You are setting a key that conflicts with a built-in method SnakyHash::StringKeyed#count defined in Enumerable. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method.` Could you advise me something here? Thanks in advance! – Kyryl Ωliinyk Mar 31 '23 at 14:31
0

I am new to rails and coding so I cannot offer any explanation to this issue and I was struggling for hours, I was using devise, so a workaround to this for me was to downgrade oauth2 version by adding:

gem 'oauth2', '~> 1.0'

in my Gemfile and running:

$ bundle install

My guess is this has something to do with JSON and I am not sure if it will affect devise functionality. The answer by Bhavesh Vadhvana also works.

  • I had tried this before, but I have not only integrated Login with Linkedin, but can also login through facebook and google. If you downgrade version of oauth2 gem then login with google will not work. – Uttam Sonani Feb 01 '23 at 03:52
0

As of 2023-08 a fix for this issue is to upgrade the omniauth-linkedin-oauth2 gem to the latest version (as https://github.com/decioferreira/omniauth-linkedin-oauth2/pull/71 has been merged and released as v1.0.1).

Paweł Gościcki
  • 9,066
  • 5
  • 70
  • 81