I'd like to know which providers have been loaded for use by the OmniAuth gem. I've tried this:
OmniAuth::Strategies.constants # a method provided by the standard lib Module class
# => [:Developer, :OAuth, :Twitter]
and this:
OmniAuth.strategies.inspect # a method provided by the OmniAuth class, but which has no documentation or comments around it.
# => [OmniAuth::Strategies::OAuth]
The answer I'd expect (or want) is [:Developer, :Twitter]
as in my test code I've only loaded twitter explicitly, and the developer provided is loaded by default.
(This is all so a different library can load the correct things for it to work, dependent on what OmniAuth is running.)
If there is a way and you know of it, please let me know. Otherwise I'll be pragmatic and knock OAuth out of the list from the first example.
Ruby is 1.9.3 and OmniAuth is v1.1.1
Adding this here for Devise users, as I needed the same list as iain.
I tried using the accepted answer at the top of my devise initializer in a Rails project, but I got an error (@@providers was not defined).
After looking into the Devise source code, I used the following to get an array of symbols:
Devise.omniauth_configs.keys # => [:facebook, :twitter]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With