PHPackages                             doccheck/oauth2-doccheck - 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. doccheck/oauth2-doccheck

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

doccheck/oauth2-doccheck
========================

DocCheck OAuth 2.0 Client Provider for The PHP League OAuth2-Client

v2.1.1(1mo ago)12.8k↑102.8%MITPHPPHP &gt;=8.2

Since Jul 22Pushed 2w agoCompare

[ Source](https://github.com/DocCheck/oauth2-doccheck)[ Packagist](https://packagist.org/packages/doccheck/oauth2-doccheck)[ RSS](/packages/doccheck-oauth2-doccheck/feed)WikiDiscussions develop Synced yesterday

READMEChangelogDependencies (8)Versions (12)Used By (0)

DocCheck Provider for OAuth 2.0 Client
======================================

[](#doccheck-provider-for-oauth-20-client)

Warning

**VERSION 1 OF THIS PACKAGE IS NO LONGER ACTIVELY MAINTAINED.**Please use version 2 for new installations and upgrades:

```
composer require doccheck/oauth2-doccheck:^2.0
```

This package provides DocCheck OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).

Installation
------------

[](#installation)

To install, use composer:

```
composer require doccheck/oauth2-doccheck
```

Usage
-----

[](#usage)

Usage is the same as The League's OAuth client, using `\Doccheck\OAuth2\Client\Provider\Doccheck` as the provider.

### Configuration

[](#configuration)

When initializing the provider, you can pass the following options:

OptionTypeDescription`clientId``string`Your DocCheck Client ID.`clientSecret``string`Your DocCheck Client Secret.`redirectUri``string`The URL to redirect back to after authorization. **Must match exactly** (see below).`stateless``bool`Set to `true` if your client has a basic license or to disable the `state` parameter (defaults to `false`).`authorizationLanguage``Language`The language for the authorization page. (defaults to `Language::EN`).Important

**Redirect URL must match exactly!**
The `redirectUri` provided in the configuration **must be identical** to the one you have configured in the DocCheck CPH (Client Control Center).
Common mistakes that cause errors:

- **Missing/Extra `www`**: `https://example.com` is NOT the same as `https://www.example.com`.
- **Missing/Extra trailing slash**: `https://example.com/callback` is NOT the same as `https://example.com/callback/`.
- **Different Protocol**: `http` is NOT the same as `https`.

### Authorization Code Flow

[](#authorization-code-flow)

```
require_once('./vendor/autoload.php');

use Doccheck\OAuth2\Client\Provider\Doccheck;
use Doccheck\OAuth2\Client\Utils\Language;

session_start();

$provider = new Doccheck([
    'clientId'              => '{doccheck-client-id}',
    'clientSecret'          => '{doccheck-client-secret}',
    'redirectUri'           => 'https://example.com/callback-url',
    'stateless'            => false, // set true if client has basic license or to prevent state parameter
    'authorizationLanguage' => Language::DE, // Optional: defaults to EN
]);

if (!isset($_GET['code'])) {
    // If we don't have an authorization code then get one
    $authUrl = $provider->getAuthorizationUrl([
        'scope' => ['email'], // Add required scopes
    ]);
    $_SESSION['oauth2state'] = $provider->getState();
    header('Location: '.$authUrl);
    exit;
// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {
    unset($_SESSION['oauth2state']);
    exit('Invalid state');
} else {
    // Try to get an access token (using the authorization code grant)
    $token = $provider->getAccessToken('authorization_code', [
        'code' => $_GET['code']
    ]);

    // Optional: Now you have a token you can look up a users profile data
    try {

        // We got an access token, let's now get the user's details
        $user = $provider->getResourceOwner($token);

        // Use these details to create a new profile
        printf('Hello %s!', $user->getEmail());

    } catch (Exception $e) {

        // Failed to get user details
        exit('Oh dear... ' . $e->getMessage());
    }

    // Use this to interact with an API on the users behalf
    // echo $token->getToken();
}
```

### Resource Owner

[](#resource-owner)

The `getResourceOwner` method returns a `DoccheckResourceOwner` instance which provides the following methods:

- `getId()`: The unique DocCheck user ID.
- `getEmail()`: The user's email address.
- \[...\]
- `toArray()`: Returns all available user data as an array.

*Note: Availability of data depends on the requested scopes and the user's DocCheck account.*

Testing
-------

[](#testing)

```
$ ./vendor/bin/phpunit
```

License
-------

[](#license)

The MIT License (MIT).

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance94

Actively maintained with recent releases

Popularity25

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.5% of commits — single point of failure

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.

###  Release Activity

Cadence

Every ~36 days

Recently: every ~67 days

Total

10

Last Release

18d ago

Major Versions

v1.0.0 → v2.0.0-BETA12025-07-22

v1.0.1 → v2.0.0-BETA22025-07-30

v1.1.1 → v2.0.0-BETA42025-09-19

PHP version history (2 changes)v1.0.0PHP &gt;=7.2

v2.0.0-BETA1PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ad735e19ea0aed09e43d9957845eb27761f8a067fa0f77d02efb6f2e6fe0c4e?d=identicon)[dcit](/maintainers/dcit)

---

Top Contributors

[![dc-magnus](https://avatars.githubusercontent.com/u/135117657?v=4)](https://github.com/dc-magnus "dc-magnus (15 commits)")[![dcsvenbroeker](https://avatars.githubusercontent.com/u/83357969?v=4)](https://github.com/dcsvenbroeker "dcsvenbroeker (7 commits)")[![dc-christian](https://avatars.githubusercontent.com/u/141313748?v=4)](https://github.com/dc-christian "dc-christian (2 commits)")

---

Tags

clientoauthoauth2authorizationauthorisationdoccheck

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/doccheck-oauth2-doccheck/health.svg)

```
[![Health](https://phpackages.com/badges/doccheck-oauth2-doccheck/health.svg)](https://phpackages.com/packages/doccheck-oauth2-doccheck)
```

###  Alternatives

[stevenmaguire/oauth2-keycloak

Keycloak OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2306.4M45](/packages/stevenmaguire-oauth2-keycloak)[thenetworg/oauth2-azure

Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client

25310.7M83](/packages/thenetworg-oauth2-azure)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1152.8M12](/packages/patrickbussmann-oauth2-apple)[omines/oauth2-gitlab

GitLab OAuth 2.0 Client Provider for The PHP League OAuth2-Client

36779.2k16](/packages/omines-oauth2-gitlab)[league/oauth2-instagram

Instagram OAuth 2.0 Client Provider for The PHP League OAuth2-Client

661.1M48](/packages/league-oauth2-instagram)[mollie/oauth2-mollie-php

Mollie Provider for OAuth 2.0 Client

261.8M1](/packages/mollie-oauth2-mollie-php)

PHPackages © 2026

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