Skip to content
docsv0.1.0

GitLabOAuthService

GitLab OAuth 2.0 protocol implementation. Supports both gitlab.com and self-hosted instances via configurable instanceUrl. Set GITLAB_INSTANCE_URL to your private GitLab base URL (e.g. https://git.mycompany.com). Defaults to https://gitlab.com when not set.

GitLabOAuthService::__construct()

public function __construct(string $clientId, string $clientSecret, string $instanceUrl = ''):

Parameters

Parameters of __construct()
NameTypeDescription
$clientIdstring
$clientSecretstring
$instanceUrlstring

GitLabOAuthService::getAuthUrl()

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

Build the authorization URL against the configured GitLab instance (gitlab.com by default, or the self-hosted instanceUrl given at construction).

Parameters

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

GitLabOAuthService::exchangeCode()

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

Exchange the authorization code for an access token, then fetch the profile from the configured instance's API.

Parameters

Parameters of exchangeCode()
NameTypeDescription
$codestring
$redirectUristring

GitLabOAuthService::getInstanceUrl()

public function getInstanceUrl(): string