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
OmniAuth::Strategies lists strategies available and registered. Not those that are in ‘use’. If you dig through the code of OmniAuth builder, you will see that various strategies are passed onto Rack using
useas middleware in the provider block, which makes tracking the strategies harder. Another “pragmatic” approach is to monkey patch OmniAuth Builder and track the providers.Include this patch before configuring your providers. Once all the providers have been loaded,
OmniAuth::Builder.providerswill give you the array you want.Even though Developer strategy is available, it is not loaded. It is only loaded if you specify