Module: Auth0::Mixins::Initializer
- Included in:
- Auth0::Mixins
- Defined in:
- lib/auth0/mixins/initializer.rb
Overview
Help class where Auth0::Client initialization described
Class Method Summary (collapse)
-
+ (Object) included(klass)
including initializer in top of klass.
Instance Method Summary (collapse)
-
- (Object) initialize(config)
Default initialization mechanism, moved here to keep Auth0::Client clear accepts hash as parameter you can get all required fields from here: auth0.com/docs/auth-api.
Class Method Details
+ (Object) included(klass)
including initializer in top of klass
26 27 28 |
# File 'lib/auth0/mixins/initializer.rb', line 26 def self.included(klass) klass.send :prepend, Initializer end |
Instance Method Details
- (Object) initialize(config)
Default initialization mechanism, moved here to keep Auth0::Client clear accepts hash as parameter you can get all required fields from here: auth0.com/docs/auth-api
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/auth0/mixins/initializer.rb', line 8 def initialize(config) = Hash[config.map{|(k,v)| [k.to_sym,v]}] self.class.base_uri "https://#{[:namespace]}" self.class.headers "Content-Type" => 'application/json' if [:protocols].to_s.include?("v2") self.extend Auth0::Api::V2 @token = [:access_token] else self.extend Auth0::Api::V1 self.extend Auth0::Api::AuthenticationEndpoints @client_id = [:client_id] @client_secret = [:client_secret] @token = obtain_access_token end self.class.headers "Authorization" => "Bearer #{[:access_token]}" end |