Method: Auth0::Api::V2::DeviceCredentials#create_device_credential

Defined in:
lib/auth0/api/v2/device_credentials.rb

#create_device_credential(device_name, value, device_id, client_id) ⇒ json Also known as: create_device_public_key

Creates a new device public key.

Parameters:

  • device_name (string)

    The device’s name, a value that must be easily recognized by the device’s owner.

  • value (string)

    A base64 encoded string with the value of the credential.

  • device_id (string)

    A unique identifier for the device.

  • client_id (string)

    The client_id of the client for which the credential will be created.

Returns:

  • (json)

    Returns the created public key.

Raises:

See Also:



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/auth0/api/v2/device_credentials.rb', line 48

def create_device_credential(device_name, value, device_id, client_id)
  raise Auth0::InvalidParameter, 'Must supply a valid device_name' if device_name.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply a valid value' if value.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply a valid device_id' if device_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply a valid client_id' if client_id.to_s.empty?
  request_params = {
    device_name:  device_name,
    type:         'public_key',
    value:        value,
    device_id:    device_id,
    client_id:    client_id
  }
  post(device_credentials_path, request_params)
end