You are here

function hook_farm_api_oauth2_client in farmOS 7

Provide a client to the farmOS OAuth2 Server.

Return value

array Returns an array of oauth2 clients.

Related topics

3 functions implement hook_farm_api_oauth2_client()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

farm_api_development_farm_api_oauth2_client in modules/farm/farm_api/farm_api_development/farm_api_development.module
Implements hook_farm_api_oauth2_client().
farm_api_farm_api_oauth2_client in modules/farm/farm_api/farm_api.module
farm_client_farm_api_oauth2_client in modules/farm/farm_client/farm_client.module
Implements hook_farm_api_oauth2_client().
2 invocations of hook_farm_api_oauth2_client()
farm_api_oauth_settings_form in modules/farm/farm_api/farm_api.oauth.inc
OAuth client configuration form.
farm_api_oauth_settings_form_submit in modules/farm/farm_api/farm_api.oauth.inc
Form submit handler for farm_api_oauth_settings_form

File

modules/farm/farm_api/farm_api.api.php, line 67
Hooks provided by farm_api.

Code

function hook_farm_api_oauth2_client() {
  $clients = array();

  // Define an array of redirect URI's used by the third party for the
  // OAuth Authorization Flow.
  $redirect_uris = array(
    'https://authorize.domain.com',
    'https://third.party.com/authorize',
  );
  $clients['third_party_name'] = array(
    // A name for the OAuth2 Client that will be displayed to farmOS Admins.
    'label' => 'Third Party Feature Integration',
    // Unique client machine name.
    'client_key' => 'third_party_machine_name',
    // Optional. OAuth Clients can require a client_secret to authorize with
    // that client. Most 3rd parties won't need this because the code
    // implementing this hook will likely be open source.
    // 'client_secret' => 'secret',
    // The oauth2_server module supports multiple redirect URIs separated by a
    // newline. Both a dummy and the real uri are specified to confirm that
    // validation passes.
    'redirect_uri' => implode("\n", $redirect_uris),
    // Optional. OAuth Clients can override some server-level OAuth settings.
    // Only supply these settings if overriding grant types.
    'settings' => array(
      'override_grant_types' => TRUE,
      // Allow the Implicit Grant type.
      'allow_implicit' => FALSE,
      // List of grant types the client will support.
      'grant_types' => array(
        'authorization_code' => 'authorization_code',
        'client_credentials' => 'client_credentials',
        'password' => 'password',
        'refresh_token' => 'refresh_token',
      ),
      // These do not default to the server default. Set these
      // settings when overriding server-level settings.
      'always_issue_new_refresh_token' => TRUE,
      'unset_refresh_token_after_use' => TRUE,
    ),
  );
  return $clients;
}