You are here

public function Authentication::oauth_token in Auth0 Single Sign On 8.2

Makes a call to the `oauth/token` endpoint.

Parameters

array $options Options for the token endpoint request.:

  • options.grant_type Grant type to use; required.
  • options.client_id Application Client ID; required.
  • options.client_secret Application Client Secret; required if token endpoint requires authentication.
  • options.scope Access token scope requested.
  • options.audience API audience identifier for access token.

Return value

mixed

Throws

ApiException If grant_type is missing from $options.

5 calls to Authentication::oauth_token()
Authentication::client_credentials in vendor/auth0/auth0-php/src/API/Authentication.php
Makes a call to the `oauth/token` endpoint with `client_credentials` grant type.
Authentication::code_exchange in vendor/auth0/auth0-php/src/API/Authentication.php
Makes a call to the `oauth/token` endpoint with `authorization_code` grant type
Authentication::login in vendor/auth0/auth0-php/src/API/Authentication.php
Makes a call to the `oauth/token` endpoint with `password-realm` grant type.
Authentication::login_with_default_directory in vendor/auth0/auth0-php/src/API/Authentication.php
Makes a call to the `oauth/token` endpoint with `password` grant type
Authentication::refresh_token in vendor/auth0/auth0-php/src/API/Authentication.php
Use a refresh token grant to get new tokens.

File

vendor/auth0/auth0-php/src/API/Authentication.php, line 348

Class

Authentication
Class Authentication

Namespace

Auth0\SDK\API

Code

public function oauth_token(array $options = []) {
  if (!isset($options['client_id'])) {
    $options['client_id'] = $this->client_id;
  }
  if (!isset($options['client_secret'])) {
    $options['client_secret'] = $this->client_secret;
  }
  if (!isset($options['grant_type'])) {
    throw new ApiException('grant_type is mandatory');
  }
  $request = $this->apiClient
    ->method('post')
    ->addPath('oauth/token')
    ->withBody(json_encode($options));
  if (isset($options['auth0_forwarded_for'])) {
    $request
      ->withHeader(new ForwardedFor($options['auth0_forwarded_for']));
  }
  return $request
    ->call();
}