function media_acquiadam_oauth2_clients in Media: Acquia DAM 7
Implements hook_oauth2_clients().
File
- ./
media_acquiadam.module, line 149
Code
function media_acquiadam_oauth2_clients() {
global $base_url;
$client_url = $base_url;
$server_url = variable_get('media_acquiadam_api_endpoint', 'https://apiv2.webdamdb.com');
$base_auth = [
'token_endpoint' => $server_url . '/oauth2/token',
'client_id' => variable_get('media_acquiadam_client_id'),
'client_secret' => variable_get('media_acquiadam_client_secret'),
];
// This setup redirects the user to the Acquia DAM OAuth2 endpoint for
// authentication instead of passing username/password information from Drupal
// to Acquia DAM.
$oauth2_clients['acquiadam-server-auth'] = $base_auth + [
'auth_flow' => 'server-side',
'authorization_endpoint' => $server_url . '/oauth2/authorize',
'redirect_uri' => $client_url . '/oauth2/authorized',
];
// This method requires configuration of a username and password so it is
// inherently less secure than handing authentication off to the user. We only
// use this for the background user and never regular Drupal users.
$oauth2_clients['acquiadam-user-auth'] = $base_auth + [
'auth_flow' => 'user-password',
'username' => variable_get('media_acquiadam_background_user'),
'password' => variable_get('media_acquiadam_background_pass'),
];
// Client credentials are not supported but still defined here.
$oauth2_clients['acquiadam-client-auth'] = $base_auth + [
'auth_flow' => 'client-credentials',
];
return $oauth2_clients;
}