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
| Name | Type | Description |
|---|---|---|
| $clientId | string | |
| $clientSecret | string | |
| $instanceUrl | string |
GitLabOAuthService::getAuthUrl()
public function getAuthUrl(string $redirectUri, ?string $state = null): stringBuild the authorization URL against the configured GitLab instance (gitlab.com by default, or the self-hosted instanceUrl given at construction).
Parameters
| Name | Type | Description |
|---|---|---|
| $redirectUri | string | |
| $state | ?string |
GitLabOAuthService::exchangeCode()
public function exchangeCode(string $code, string $redirectUri): Milpa\OAuth\DTO\GitLabUserInfoExchange the authorization code for an access token, then fetch the profile from the configured instance's API.
Parameters
| Name | Type | Description |
|---|---|---|
| $code | string | |
| $redirectUri | string |
GitLabOAuthService::getInstanceUrl()
public function getInstanceUrl(): string