We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I want to dynamically look up a specific OmniAuth strategy by its :name. For example, the Google strategy has the name of 'google_oauth2' (code).
:name
OmniAuth.strategies is a list of classes:
OmniAuth.strategies
[ [ 0] OmniAuth::Strategies::OAuth2 < Object, [ 1] OmniAuth::Strategies::Asana < OmniAuth::Strategies::OAuth2, [ 2] OmniAuth::Strategies::Bitbucket < OmniAuth::Strategies::OAuth2, ...
It doesn't seem there's a class property for :name, so to find a strategy by name I have to create instances:
strategy_klass = OmniAuth.strategies.find do |klass| instance = klass.new(nil) instance.name == 'google_oauth2' end # strategy_klass is now OmniAuth::Strategies::GoogleOauth2 < OmniAuth::Strategies::OAuth2
Is there a more recommended way to find a strategy by :name? I looked through the docs and code and didn't see one.
Thanks for the time you put into OmniAuth, it's amazing. 🙏
The text was updated successfully, but these errors were encountered:
I found this https://github.com/omniauth/omniauth/blob/master/lib/omniauth/builder.rb#L52
middleware = OmniAuth::Strategies.const_get(OmniAuth::Utils.camelize('google_oauth2').to_s) # returns OmniAuth::Strategies::GoogleOauth2
I guess now I want to automatically create an instance of the provider with the configuration given in my Rails config/initializers/omniauth.rb
provider :google_oauth2, ENV["GOOGLE_OAUTH_CLIENT_ID"], ENV["GOOGLE_OAUTH_CLIENT_SECRET"], scope: "(...scopes...)"
Are there any ways to get the pre-configured instance of a strategy?
Sorry, something went wrong.
Same question over here. @aguynamedben did you find a solution for this?
@kreintjes I don't recall, too much time passed!
No branches or pull requests
I want to dynamically look up a specific OmniAuth strategy by its
:name
. For example, the Google strategy has the name of 'google_oauth2' (code).OmniAuth.strategies
is a list of classes:It doesn't seem there's a class property for
:name
, so to find a strategy by name I have to create instances:Is there a more recommended way to find a strategy by
:name
? I looked through the docs and code and didn't see one.Thanks for the time you put into OmniAuth, it's amazing. 🙏
The text was updated successfully, but these errors were encountered: