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

Take OAuth tokens fron global provider options #49

Open
mildred opened this issue Jul 23, 2019 · 0 comments
Open

Take OAuth tokens fron global provider options #49

mildred opened this issue Jul 23, 2019 · 0 comments

Comments

@mildred
Copy link

mildred commented Jul 23, 2019

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)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant