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
-
.included(klass) ⇒ Object
including initializer in top of klass.
Instance Method Summary collapse
-
#initialize(config) ⇒ Object
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
.included(klass) ⇒ Object
including initializer in top of klass
25 26 27 |
# File 'lib/auth0/mixins/initializer.rb', line 25 def self.included(klass) klass.send :prepend, Initializer end |
Instance Method Details
#initialize(config) ⇒ Object
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
To run using api v2, pass api_version: 2 when creating a client
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/auth0/mixins/initializer.rb', line 10 def initialize(config) = Hash[config.map{|(k,v)| [k.to_sym,v]}] domain = api_domain raise InvalidApiNamespace, "Api namespace must supply an API domain" if domain.nil? self.class.base_uri "https://#{domain}" self.class.headers client_headers(config) self.extend Auth0::Api::AuthenticationEndpoints @client_id = [:client_id] initialize_v2() if api_v2?() initialize_v1() if api_v1?() raise InvalidCredentials, "Must supply a valid API token" if @token.nil? self.class.headers "Authorization" => "Bearer #{@token}" end |