pow-auth / pow_assent

Multi-provider authentication for your Pow enabled app
https://powauth.com
MIT License
325 stars 50 forks source link

Failing to authenticate on Twitter when using Mint 1.0 #119

Closed hok closed 4 years ago

hok commented 4 years ago

I was adding PowAssent using Twitter strategy and the authentication process worked until the get_user function was called, at which point Twitter returned

{ "code": 32, "message": "Could not authenticate you." }

I was using Mint 1.0 as the HTTP client. During debugging I went back to httpc, which fixed the issue. It might be some kind of encoding problem but I couldn't make it work so far using Mint.

hok commented 4 years ago

Actually this code is in Assent so I might have created this ticket in the wrong place.

The failure happens in deps/assent/lib/assent/strategies/oauth.ex:208, on the get line:

  def get_user(config, token) do
    with {:ok, url} <- Config.fetch(config, :user_url) do
      config
      |> get(token, url)
      |> process_user_response()
    end
  end
danschultzer commented 4 years ago

I think it's because query params was not passed on to the Mint request. Can you try with Mint again, using this branch in mix.exs?

{:assent, github: "pow-auth/assent", ref: "fix-mint-query", override: true}

It hopefully solves the issue 😄

hok commented 4 years ago

It does work with the fix branch.

Thanks for looking into it. Pow and PowAssent are awesome libraries.

danschultzer commented 4 years ago

Assent v0.1.5 released with the fix 🚀