pow-auth / assent

Multi-provider framework in Elixir
https://powauth.com
MIT License
406 stars 47 forks source link

Change scopes and openid_default_scope #121

Closed johns10 closed 1 year ago

johns10 commented 1 year ago

This strategy didn't work. I had to make a custom strategy with these configs.

danschultzer commented 1 year ago

You should use Sign In with LinkedIn v2. Sign In with LinkedIn v1 is an OAuth 2.0 strategy, but the LinkedIn stategy is using OIDC. Linkedin conflates the two so this kinda works. I'll make a stronger note in the module doc.

danschultzer commented 1 year ago

The docs have been updated: https://github.com/pow-auth/assent/blob/main/lib/assent/strategies/linkedin.ex

johns10 commented 1 year ago

I did some more work on this before it actually worked. Here's how I made it work in my app:

defmodule Savr.LinkedinStrategy do
  use Assent.Strategy.OAuth2.Base

  @impl true
  def default_config(_config) do
    [
      site: "https://www.linkedin.com",
      authorize_url: "https://www.linkedin.com/oauth/v2/authorization",
      token_url: "https://www.linkedin.com/oauth/v2/accessToken",
      user_url: "https://api.linkedin.com/v2/me",
      authorization_params: [scope: "r_emailaddress r_liteprofile"],
      auth_method: :client_secret_post
    ]
  end

  @impl true

  def normalize(_config, user) do
    {:ok,
     %{
       "sub" => user["id"],
       "name" => user["localizedFirstName"] <> user["localizedLastName"],
       "email" => user["email"]
     }}
  end
end
johns10 commented 1 year ago

I will go and try what you've recommended now. Their auth seems like a bit of a cluster ****

johns10 commented 1 year ago

Hot dang dude, first time through!! This knowledge would have saved my client about $300 hahaaa

The module I posted above works for the V1 auth, in case anyone ever cares.