Module: Auth0::Mixins::Headers

Included in:
Auth0::Mixins
Defined in:
lib/auth0/mixins/headers.rb

Overview

Module to provide necessary headers for API requests.

Instance Method Summary collapse

Instance Method Details

#client_headersObject



27
28
29
30
31
32
# File 'lib/auth0/mixins/headers.rb', line 27

def client_headers
  {
    'Content-Type' => 'application/json',
    'Auth0-Client' => telemetry_encoded
  }
end

#telemetryObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/auth0/mixins/headers.rb', line 7

def telemetry
  telemetry_hash = {
    name: 'ruby-auth0',
    version: Auth0::VERSION,
    env: {
      ruby: RUBY_VERSION
    }
  }

  if Gem.loaded_specs['rails'].respond_to? :version
    telemetry_hash[:env][:rails] = Gem.loaded_specs['rails'].version.to_s
  end

  telemetry_hash
end

#telemetry_encodedObject



23
24
25
# File 'lib/auth0/mixins/headers.rb', line 23

def telemetry_encoded
  Base64.urlsafe_encode64(JSON.dump(telemetry))
end