Skip to content

Commit

Permalink
fix(tokens): Fix refresh token functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
wearethefoos committed Feb 29, 2024
1 parent 5eebc76 commit 93064a0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 42 deletions.
25 changes: 0 additions & 25 deletions lib/ueberauth/strategy/mollie.ex
Original file line number Diff line number Diff line change
Expand Up @@ -98,31 +98,6 @@ defmodule Ueberauth.Strategy.Mollie do
redirect!(conn, apply(module, :authorize_url!, [params, opts]))
end

# def handle_request!(conn) do
# send_redirect_uri = Keyword.get(options(conn), :send_redirect_uri, true)

# opts =
# if send_redirect_uri do
# [redirect_uri: callback_url(conn)]
# else
# []
# end

# opts =
# opts
# |> with_state_param(conn)

# if conn.params["state"], do: Keyword.put(opts, :state, conn.params["state"]), else: opts

# opts =
# if conn.params["scope"],
# do: Keyword.put(opts, :scope, conn.params["scope"]),
# else: Keyword.put(opts, :scope, option(conn, :default_scope))

# module = option(conn, :oauth2_module)
# redirect!(conn, apply(module, :authorize_url!, [opts]))
# end

@doc """
Handles the callback from Mollie Connect.
When there is a failure from Mollie the failure is included in the
Expand Down
21 changes: 4 additions & 17 deletions lib/ueberauth/strategy/mollie/oauth.ex
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,13 @@ defmodule Ueberauth.Strategy.Mollie.OAuth do
client.token
end

def refresh_auth_token!(params \\ [], options \\ []) do
def refresh_auth_token!(token, params \\ [], options \\ []) do
headers = Keyword.get(options, :headers, [])
options = Keyword.get(options, :options, [])
client_options = Keyword.get(options, :client_options, [])
client_options = Keyword.get(options, :client_options, token: token)

client = client(client_options)

request =
client
|> put_param("client_secret", client.client_secret)
|> put_header("Accept", "application/json")
|> Mollie.AuthCode.refresh_auth_token(params, headers)

case OAuth2.Client.post(
request,
client.token_url,
request.params,
request.headers
) do
{:ok, response} -> {:ok, OAuth2.AccessToken.new(response.body)}
case OAuth2.Client.refresh_token(client(client_options), params, headers, options) do
{:ok, response} -> {:ok, response.token}
{:error, error} -> {:error, error}
end
end
Expand Down

0 comments on commit 93064a0

Please sign in to comment.