Skip to content

Take OAuth tokens fron global provider options #49

@mildred

Description

@mildred

The main issue is ueberauth/ueberauth#106 and the use case is to allow dynamic ueberauth providers. To make it simple, the OAuth client id and secret are not available through configuration or environment variable, but are dynamic in database.

The GitHub provider needs to be able to fetch the client id and secret from a dynamic source, not only the configuration. I suggest to allow them be put in options(conn).

The code already has some part allowing that. Ueberauth.Strategy.Github.OAuth.client() already takes an options argument that it merges with the global configuration. Only it's not wired in callers.

This is not the only place but for example at https://github.com/ueberauth/ueberauth_github/blob/master/lib/ueberauth/strategy/github.ex#L112 we could do:

  def handle_callback!(%Plug.Conn{params: %{"code" => code}} = conn) do
    module = option(conn, :oauth2_module)
-    token = apply(module, :get_token!, [[code: code]])
+    token = apply(module, :get_token!, [[code: code], options(conn)])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions