POW Assent Routes


I am trying to add pow assent routes to a button, But I am running into an error. The informations are below:


config :profilo, :pow_assent,
  providers: [
    github: [
      client_id: "secret",
      client_secret: "secret",
      strategy: PowAssent.Strategy.Github


<h1>Sign in</h1>

<%= form_for @changeset, @action, [as: :user], fn f -> %>
  <%= if @changeset.action do %>
    <div class="alert alert-danger">
      <p>Oops, something went wrong! Please check the errors below.</p>
  <% end %>

  <%= label f, @changeset.data.__struct__.pow_user_id_field() %>
  <%= text_input f, @changeset.data.__struct__.pow_user_id_field() %>
  <%= error_tag f, @changeset.data.__struct__.pow_user_id_field() %>

  <%= label f, :password %>
  <%= password_input f, :password %>
  <%= error_tag f, :password %>

    <%= submit "Sign in" %>
<% end %>

<span><%= link "Register", to: Routes.pow_registration_path(@conn, :new) %></span>
<div><%= link "Register with Github", to: Routes.pow_assent_authorization_path(@conn, :new, providers: "github") %></div>
<div><%= link "Register with Github", to: "/auth/github/new " %></div>


equest: GET /auth/provider/new
** (exit) an exception was raised:
    ** (PowAssent.Config.ConfigError) No provider configuration available for provider.

The error is raised in the https://github.com/danschultzer/pow_assent/blob/cdc7d97e8fb776ff226df8ee50d99c1237cc0453/lib/pow_assent/config.ex#L58

Try replacing "github" to :github in the route helper.

1 Like

Hey @jung-hunsoo, I tried that you suggested. I am getting the following:

Snippet code I tried

<div><%= link "Sign with Github", to: Routes.pow_assent_authorization_path(@conn, :new, providers: :github) %></div>


Protocol.UndefinedError at GET /session/new
protocol Phoenix.Param not implemented for [providers: :github]. This protocol is implemented for: Any, Map, Integer, BitString, Atom

I was able to get it to work by making the following update:

<div><%= link "Sign with Github", to: Routes.pow_assent_authorization_path(@conn, :new, :github) %></div>

Thank you @jung-hunsoo

Alternatively, you can use the PowAssent.Phoenix.ViewHelpers module for this:

# All links
<%= for link <- PowAssent.Phoenix.ViewHelpers.provider_links(@conn),
  do: content_tag(:div, link) %>
# Individual sign in link
<div><%= PowAssent.Phoenix.ViewHelpers.provider_link(@conn, :github, []) %></div>