<?php
namespace XF\ConnectedAccount\Provider;
use XF\Entity\ConnectedAccountProvider;
use XF\ConnectedAccount\Http\HttpResponseException;
class Google extends AbstractProvider
{
public function getOAuthServiceName()
{
return 'Google';
}
public function getDefaultOptions()
{
return [
'client_id' => '',
'client_secret' => ''
];
}
public function getOAuthConfig(ConnectedAccountProvider $provider, $redirectUri = null)
{
return [
'key' => $provider->options['client_id'],
'secret' => $provider->options['client_secret'],
'scopes' => ['profile', 'email'],
'redirect' => $redirectUri ?: $this->getRedirectUri($provider)
];
}
public function parseProviderError(HttpResponseException $e, &$error = null)
{
$errorDetails = json_decode($e->getResponseContent(), true);
if (isset($errorDetails['error_description']))
{
$e->setMessage($errorDetails['error_description']);
}
parent::parseProviderError($e, $error);
}
public function getIconUrl()
{
return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACUAAAAmCAYAAABDClKtAAABS2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDIgNzkuMTYwOTI0LCAyMDE3LzA3LzEzLTAxOjA2OjM5ICAgICAgICAiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIi8+CiA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgo8P3hwYWNrZXQgZW5kPSJyIj8+nhxg7wAAA11JREFUWIXNmL9vUlEYhp/a3sYiUWIiDk1burkYqYHFRSqNkwOVhcREWxMXl9rJgUFNWnWr/QuKGw4EBrsVpJMmNBHjoulQbGJq0DQ0XrVIbR3ugcDt/XGgV+KbEOCec977cPjOd79z4D9UT6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