You are here

function oauth2_user_wsclient_auth_settings in OAuth2 Login 8

Same name and namespace in other branches
  1. 7.2 oauth2_user/oauth2_user.api.php \oauth2_user_wsclient_auth_settings()

Return authentication settings.

It can be used when defining a wsclient service, like this: $service->settings += oauth2_user_wsclient_auth_settings();

File

oauth2_user/oauth2_user.api.php, line 136
Functions that can be used by other modules.

Code

function oauth2_user_wsclient_auth_settings() {
  $server_url = variable_get('oauth2_login_oauth2_server', '');
  $client_id = variable_get('oauth2_login_client_id', '');
  $client_secret = variable_get('oauth2_login_client_secret', '');
  $token_endpoint = $server_url . '/oauth2/token';
  $authorization_endpoint = $server_url . '/oauth2/authorize';
  $redirect_uri = url('oauth2/authorized', [
    'absolute' => TRUE,
  ]);
  $auth_settings['authentication']['oauth2'] = [
    'token_endpoint' => $token_endpoint,
    'auth_flow' => 'server-side',
    'client_id' => $client_id,
    'client_secret' => $client_secret,
    'redirect_uri' => $redirect_uri,
    'authorization_endpoint' => $authorization_endpoint,
    'scope' => 'user_profile',
  ];
  return $auth_settings;
}