Module: Auth0::Api::V2::ResourceServers

Included in:
Auth0::Api::V2
Defined in:
lib/auth0/api/v2/resource_servers.rb

Overview

Methods to use the resource servers endpoints

Instance Method Summary collapse

Instance Method Details

#create_resource_server(identifier, options = {}) ⇒ json

Creates a new resource server according to the JSON object received in body.

Parameters:

  • identifier (string)

    The identifier of the resource server.

  • options (hash) (defaults to: {})
    • :name [string] The name of the resource server. Must contain at least one character. Does not allow '<' or '>'.

    • :signing_alg [string] The algorithm used to sign tokens.

    • :signing_secret [string] The secret used to sign tokens when using symmetric algorithms.

    • :token_lifetime [integer] The amount of time (in seconds) that the token will be valid after being issued.

    • :scopes [array] The scope of the resource server.

Returns:

  • (json)

    Returns the resource server.

Raises:

See Also:



32
33
34
35
36
37
38
39
40
# File 'lib/auth0/api/v2/resource_servers.rb', line 32

def create_resource_server(identifier, options = {})
  raise Auth0::InvalidParameter, 'Must supply a valid resource server id' if identifier.to_s.empty?
  if options.fetch(:name, '').index(/[<>]/)
    raise Auth0::InvalidParameter, 'Name must contain at least one character. Does not allow "<" or ">"'
  end
  request_params = Hash[options.map { |(k, v)| [k.to_sym, v] }]
  request_params[:identifier] = identifier
  post(resource_servers_path, request_params)
end

#delete_resource_server(resource_server_id) ⇒ Object

Deletes a resource server by its ID.

Parameters:

  • resource_server_id (string)

    The id of the resource server to delete.

Raises:

See Also:



45
46
47
48
49
# File 'lib/auth0/api/v2/resource_servers.rb', line 45

def delete_resource_server(resource_server_id)
  raise Auth0::InvalidParameter, 'Must supply a valid resource server id' if resource_server_id.to_s.empty?
  path = "#{resource_servers_path}/#{resource_server_id}"
  delete(path)
end

#resource_server(resource_server_id) ⇒ json Also known as: get_resource_server

Retrieves a resource server by its ID.

Parameters:

  • resource_server_id (string)

    The id of the resource server to retrieve.

Returns:

  • (json)

    Returns the resource server.

Raises:

See Also:



13
14
15
16
17
# File 'lib/auth0/api/v2/resource_servers.rb', line 13

def resource_server(resource_server_id)
  raise Auth0::InvalidParameter, 'Must supply a valid resource server id' if resource_server_id.to_s.empty?
  path = "#{resource_servers_path}/#{resource_server_id}"
  get(path)
end