Class: Auth0Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/auth0/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Auth0Client

Returns a new instance of Auth0Client.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/auth0/client.rb', line 7

def initialize(options)
  self.class.base_uri "https://#{options[:namespace]}"

  token_reponse = self.class.post("/oauth/token", {
    body: {
      'client_id'     => options[:client_id],
      'client_secret' => options[:client_secret],
      'grant_type'    => 'client_credentials'
    }
  })

  unless token_reponse.code == 200
    raise "Error geting the token: #{token_reponse.body}"
  end

  @token = token_reponse["access_token"]
  @headers = {
    "Authorization" => "Bearer #{@token}"
  }
end

Instance Method Details

#get_connectionsObject



28
29
30
31
# File 'lib/auth0/client.rb', line 28

def get_connections
  response = self.class.get("/api/connections", { headers: @headers })
  response.body
end