OpenIDConnectGoogleClient.php in OpenID Connect / OAuth client 8
File
src/Plugin/OpenIDConnectClient/OpenIDConnectGoogleClient.php
View source
<?php
namespace Drupal\openid_connect\Plugin\OpenIDConnectClient;
use Drupal\Core\Form\FormStateInterface;
use Drupal\openid_connect\Plugin\OpenIDConnectClientBase;
class OpenIDConnectGoogleClient extends OpenIDConnectClientBase {
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$url = 'https://console.developers.google.com/project/_/apiui/apis/library';
$form['description'] = [
'#markup' => '<div class="description">' . $this
->t('Set up your app in <a href="@url" target="_blank">Google API Console</a>.', [
'@url' => $url,
]) . '</div>',
];
return $form;
}
public function getEndpoints() {
return [
'authorization' => 'https://accounts.google.com/o/oauth2/v2/auth',
'token' => 'https://oauth2.googleapis.com/token',
'userinfo' => 'https://openidconnect.googleapis.com/v1/userinfo',
];
}
public function retrieveUserInfo($access_token) {
$userinfo = parent::retrieveUserInfo($access_token);
if ($userinfo) {
preg_match('/https:\\/\\/*.*/', $userinfo['picture'], $matches);
$userinfo['picture'] = $matches[0];
}
return $userinfo;
}
}