decioferreira / omniauth-linkedin-oauth2

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

How to get it working in 2024 #80

Open initseis opened 6 months ago

initseis commented 6 months ago

I had to do Monkey Patching like this:

module OmniAuth
  module Strategies
    class LinkedIn < OmniAuth::Strategies::OAuth2
      uid do
        raw_info["sub"]
      end

      info do
        {
          :name => raw_info["given_name"],
          :family_name => raw_info["family_name"],
          :email => raw_info["email"],
          :image => raw_info["picture"]
        }
      end

      extra do
        {
          "info" => raw_info
        }
      end

      def profile_endpoint
        "/v2/userinfo"
      end
    end
  end
end

And the button this way:

<%= button_to "/auth/linkedin", data: { turbo: false }, class: "px-4 py-2 border flex gap-2 border-dark rounded-lg text-dark hover:shadow transition duration-150"  do %>
  <span class="size-6">
    <%= render "icons/linkedin" %>
  </span>
  <span><%= t("pages.sign_up.sign_up_with_linkedin") %></span>
<% end %>
botularius commented 3 months ago

+1

hasghari commented 2 months ago

There's a new gem to support the OpenID auth flow: https://github.com/jclusso/omniauth-linkedin-openid