You are here

public function ResourceServers::create in Auth0 Single Sign On 8.2

Create a new Resource Server. Required scope: "create:resource_servers"

@link https://auth0.com/docs/api/management/v2#!/Resource_Servers/post_resourc...

Parameters

string $identifier API identifier to use.:

array $data Additional fields to add.:

Return value

mixed

Throws

CoreException Thrown if the identifier parameter or data field is empty or is not a string.

\Exception Thrown by the HTTP client when there is a problem with the API call.

File

vendor/auth0/auth0-php/src/API/Management/ResourceServers.php, line 85

Class

ResourceServers
Class ResourceServers. Handles requests to the Resource Servers endpoint of the v2 Management API.

Namespace

Auth0\SDK\API\Management

Code

public function create($identifier, array $data) {

  // Backwards-compatibility with previously-unused $identifier parameter.
  if (empty($data['identifier'])) {
    $data['identifier'] = $identifier;
  }
  if (empty($data['identifier']) || !is_string($data['identifier'])) {
    throw new CoreException('Invalid "identifier" field.');
  }
  return $this->apiClient
    ->method('post')
    ->addPath('resource-servers')
    ->withBody(json_encode($data))
    ->call();
}