swelham / ueberauth_microsoft

Microsoft Strategy for Überauth
MIT License
37 stars 35 forks source link

Config can be loaded dynamically #64

Closed docJerem closed 1 year ago

docJerem commented 1 year ago

Motivation

This strategy cannot be loaded dynamically as the documentation specifies, see the lower snippet.

# From Ueberauth/lib/ueberauth.ex doc

# Request authentication against a provider.

# specified dynamically in arguments. For example, you can specify in a
# controller:

      def request(conn, %{"provider_name" => provider_name} = _params) do
        provider_config = case provider_name do
          "github" ->
            { Ueberauth.Strategy.Github, [
              default_scope: "user",
              request_path:  provider_auth_path(conn, :request, provider_name),
              callback_path: provider_auth_path(conn, :callback, provider_name),
            ]}
        end
        conn
        |> Ueberauth.run_request(provider_name, provider_config)
      end

Current behaviour

The request phase is stucked during the loading in the OAuth module in the Keyword merging in client/1.

Fix

Like the Google Ueberauth strategy, the fix is quiet easy :

# lib / Ueberauth / strategy / microsoft / oauth.ex line 9

    config = Application.get_env(:ueberauth, __MODULE__, [])
swelham commented 1 year ago

Hi @docJerem, thanks for the PR. I totally missed that when upgrading uberauth versions!