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
- #authorization_header(token) ⇒ Object
- #authorization_header_basic(options) ⇒ Object
-
#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
27 28 29 |
# File 'lib/auth0/mixins/initializer.rb', line 27 def self.included(klass) klass.send :prepend, Initializer end |
Instance Method Details
#authorization_header(token) ⇒ Object
31 32 33 |
# File 'lib/auth0/mixins/initializer.rb', line 31 def (token) add_headers('Authorization' => "Bearer #{token}") end |
#authorization_header_basic(options) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/auth0/mixins/initializer.rb', line 35 def () connection_id = .fetch(:connection_id, Auth0::Api::AuthenticationEndpoints::UP_AUTH) user = .fetch(:user, nil) password = .fetch(:password, nil) add_headers('Authorization' => "Basic #{Base64.strict_encode64("#{connection_id}\\#{user}:#{password}")}") end |
#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
By Default API v2
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/auth0/mixins/initializer.rb', line 13 def initialize(config) = Hash[config.map { |(k, v)| [k.to_sym, v] }] @base_uri = base_url() @headers = client_headers @timeout = [:timeout] || 10 @retry_count = [:retry_count] extend Auth0::Api::AuthenticationEndpoints @client_id = [:client_id] @client_secret = [:client_secret] @organization = [:organization] initialize_api() end |