Skip to content
docsv0.1.0

GitHubOAuthService

GitHub OAuth 2.0 protocol implementation. Handles the authorization code flow: build auth URL, exchange code for token, and fetch user info from the GitHub API.

GitHubOAuthService::__construct()

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

Parameters

Parameters of __construct()
NameTypeDescription
$clientIdstring
$clientSecretstring

GitHubOAuthService::getAuthUrl()

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

Build the GitHub authorization URL requesting the read:user and user:email scopes.

Parameters

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

GitHubOAuthService::exchangeCode()

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

Exchange the authorization code for an access token, then fetch the profile from the GitHub REST API.

Parameters

Parameters of exchangeCode()
NameTypeDescription
$codestring
$redirectUristring