Skip to content
docsv0.1.0

GoogleOAuthService

Google OAuth 2.0 protocol implementation. Handles the authorization code flow: build auth URL, exchange code for token, and fetch user info. Each consumer plugin provides its own redirectUri.

GoogleOAuthService::__construct()

public function __construct(string $clientId, string $clientSecret):

Parameters

Parameters of __construct()
NameTypeDescription
$clientIdstring
$clientSecretstring

GoogleOAuthService::getAuthUrl()

public function getAuthUrl(string $redirectUri, ?string $state = null): string

Build the Google consent-screen URL, requesting offline access and forcing the consent prompt so a refresh token is issued on every authorization.

Parameters

Parameters of getAuthUrl()
NameTypeDescription
$redirectUristring
$state?string

GoogleOAuthService::exchangeCode()

public function exchangeCode(string $code, string $redirectUri): Milpa\OAuth\DTO\GoogleUserInfo

Exchange the authorization code for an access token, then fetch the profile from Google's userinfo endpoint.

Parameters

Parameters of exchangeCode()
NameTypeDescription
$codestring
$redirectUristring