PHPackages                             valdask/gitlab-auth - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. valdask/gitlab-auth

AbandonedArchivedLibrary[Authentication &amp; Authorization](/categories/authentication)

valdask/gitlab-auth
===================

Simple Gitlab Oauth wrapper for PHP

120PHP

Since Jun 13Pushed 10y ago1 watchersCompare

[ Source](https://github.com/ValdasK/gitlab-auth)[ Packagist](https://packagist.org/packages/valdask/gitlab-auth)[ RSS](/packages/valdask-gitlab-auth/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

gitlab-auth
===========

[](#gitlab-auth)

Simple Gitlab Oauth wrapper to receive user information, such as email.

The main purpose of this package is to retrieve user info from Gitlab, simplifying user login and registration proccess.

Quick use
---------

[](#quick-use)

On your login page:

```
$lib = new \GitlabAuth\Auth(new GuzzleHttp\Client(), "http://mygitlab.com", "app id", "app secret", "http://myapp.com/do-login");
header('Location: ' . $lib->getLoginRedirectUrl()); exit;
```

on "" page:

```
$lib = new \GitlabAuth\Auth(new GuzzleHttp\Client(), "http://mygitlab.com", "app id", "app secret", "http://myapp.com/do-login");
var_dump($lib->getUserByCode($_GET['code'])); exit;
```

Full how-to guide
-----------------

[](#full-how-to-guide)

### 1. Initializing

[](#1-initializing)

To initialize this library, create new instance of GitlabAuth\\Auth.

Guide how to create application ID and secret can be found here: [http://doc.gitlab.com/ce/integration/oauth\_provider.html](http://doc.gitlab.com/ce/integration/oauth_provider.html)

```
$lib = new \GitlabAuth\Auth(new GuzzleHttp\Client(), "http://mygitlab.com", "app id", "app secret", "http://myapp.com/do-login");
```

### 2. Retrieving authorization URL

[](#2-retrieving-authorization-url)

First step in login proccess is to redirect user to Gitlab authorization page, where he or she accepts of denies access using their Gitlab account. This library provides simple method to create proper redirect URL.

```
$authorizationUrl = $lib->getLoginRedirectUrl();
```

You can use this URL in link and present it to user or just use proper redirect header to skip user input.

### 3. Retrieving user data

[](#3-retrieving-user-data)

When user visits authorization page, he can choose whether to accept or deny authorization. After action is chosen, he is redirected back to redirect url (set in library initialization step), with GET parameter named "code". This is used to retrieve auth token from Gitlab server, and then using that auth token user details are retrievied from Gitlab API.

Tip: do not forget to check if *$\_GET\['error'\]* exists, and if it does that means user declined the request and should not be authorized.

```
$userDetais = $lib->getUserByCode($_GET['code']);
```

User details is an array, which contain email, name, surname, and other user details. Full documentation of Gitlab user API can be found here:

### 4. (optional) Retrieving Gitlab Auth token

[](#4-optional-retrieving-gitlab-auth-token)

If you need extra Gitlab API features, which require auth token, after calling **getUserByCode** function, method **getTokenContainer** can be used which contains retrieved auth token.

```
$authToken = $lib->getTokenContainer();
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/4691744295a1e05977daa56148014f85625ffd40ccbeced05f4dde55aac8652d?d=identicon)[ValdasK](/maintainers/ValdasK)

### Embed Badge

![Health badge](/badges/valdask-gitlab-auth/health.svg)

```
[![Health](https://phpackages.com/badges/valdask-gitlab-auth/health.svg)](https://phpackages.com/packages/valdask-gitlab-auth)
```

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[beatswitch/lock

A flexible, driver based Acl package for PHP 5.4+

870304.7k2](/packages/beatswitch-lock)[amocrm/amocrm-api-library

amoCRM API Client

182728.5k6](/packages/amocrm-amocrm-api-library)[vonage/jwt

A standalone package for creating JWTs for Vonage APIs

424.1M4](/packages/vonage-jwt)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
