Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic Oauth credentials don't get included in the refresh flow #2106

Closed
taylordowns2000 opened this issue May 17, 2024 · 0 comments · Fixed by #2107
Closed

Generic Oauth credentials don't get included in the refresh flow #2106

taylordowns2000 opened this issue May 17, 2024 · 0 comments · Fixed by #2107
Assignees
Labels
bug Newly identified bug

Comments

@taylordowns2000
Copy link
Member

maybe_refresh_token is responsible for getting a new access_token for use in credentials.

  def maybe_refresh_token(%Credential{schema: schema} = credential) do
    case lookup_adapter(schema) do
      nil ->
        {:ok, credential}

      adapter ->
        token = Common.TokenBody.new(credential.body)

        if Common.still_fresh(token) do
          {:ok, credential}
        else
          wellknown_url = adapter.wellknown_url(token.sandbox)

          {:ok, refreshed_token} =
            adapter.refresh_token(token, wellknown_url)

          update_credential(credential, %{
            body:
              refreshed_token
              |> Common.TokenBody.from_oauth2_token()
              |> Lightning.Helpers.json_safe()
          })
        end
    end
  end

but the lookup_adapter function isn't detecting these new generic oauth credentials:

  def lookup_adapter(schema) do
    case :ets.lookup(:adapter_lookup, schema) do
      [{^schema, adapter}] -> adapter
      [] -> nil
    end
  end

we should make sure that all generic oauth created credentials are also checked for freshness!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Newly identified bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants