Skip to content

Commit

Permalink
Clarify method return value and doc-block for getting client credenti…
Browse files Browse the repository at this point in the history
…als:
  • Loading branch information
felixarntz committed Oct 22, 2019
1 parent a3a024e commit f482fcf
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions includes/Core/Authentication/Clients/OAuth_Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -769,28 +769,34 @@ private function get_redirect_uri() {
}

/**
* Retrieve the Site Kit oAuth secret.
* Retrieves the OAuth credentials object.
*
* @since 1.0.0
*
* @return object|null Credentials object with `web` property, or null if no credentials available.
*/
private function get_client_credentials() {
if ( false !== $this->client_credentials ) {
return $this->client_credentials;
}

if ( $this->credentials->has() ) {
$credentials = $this->credentials->get();

$this->client_credentials = (object) array(
'web' => (object) array(
'client_id' => $credentials['oauth2_client_id'],
'client_secret' => $credentials['oauth2_client_secret'],
'auth_uri' => 'https://accounts.google.com/o/oauth2/auth',
'token_uri' => 'https://oauth2.googleapis.com/token',
'auth_provider_x509_cert_url' => 'https://www.googleapis.com/oauth2/v1/certs',
'redirect_uris' => array( $this->get_redirect_uri() ),
),
);
if ( ! $this->credentials->has() ) {
return null;
}

$credentials = $this->credentials->get();

$this->client_credentials = (object) array(
'web' => (object) array(
'client_id' => $credentials['oauth2_client_id'],
'client_secret' => $credentials['oauth2_client_secret'],
'auth_uri' => 'https://accounts.google.com/o/oauth2/auth',
'token_uri' => 'https://oauth2.googleapis.com/token',
'auth_provider_x509_cert_url' => 'https://www.googleapis.com/oauth2/v1/certs',
'redirect_uris' => array( $this->get_redirect_uri() ),
),
);

return $this->client_credentials;
}
}

0 comments on commit f482fcf

Please sign in to comment.