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

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

lustmored/oauth2-lockme
=======================

LockMe OAuth2 provider

1.5.0(9mo ago)116.9k↓30.2%[1 PRs](https://github.com/lockmepl/oauth2-lockme/pulls)1GPL-3.0-or-laterPHPPHP &gt;=8.2.0CI passing

Since Nov 15Pushed 3w ago1 watchersCompare

[ Source](https://github.com/lockmepl/oauth2-lockme)[ Packagist](https://packagist.org/packages/lustmored/oauth2-lockme)[ RSS](/packages/lustmored-oauth2-lockme/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (23)Used By (1)

OAuth2 Client for LockMe
========================

[](#oauth2-client-for-lockme)

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

> **Recommendation**: For a more comprehensive integration with LockMe, we recommend using the [lustmored/lockme-sdk](https://github.com/lustmored/lockme-sdk) package, which provides a full-featured SDK for the LockMe API.

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

[](#installation)

To install, use Composer:

```
composer require lustmored/oauth2-lockme

```

Requirements
------------

[](#requirements)

The following versions of PHP are supported:

- PHP 5.6+
- PHP 7.0+
- PHP 8.0+

This package depends on:

- [league/oauth2-client](https://github.com/thephpleague/oauth2-client) (^2.2)
- PHP ext-json

Usage
-----

[](#usage)

### Authorization Code Flow

[](#authorization-code-flow)

```
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use Lockme\OAuth2\Client\Provider\Lockme;

// Initialize the provider
$provider = new Lockme([
    'clientId'     => '{lockme-client-id}',
    'clientSecret' => '{lockme-client-secret}',
    'redirectUri'  => 'https://example.com/callback-url',
]);

// If we don't have an authorization code then get one
if (!isset($_GET['code'])) {

    // Get authorization URL
    $authorizationUrl = $provider->getAuthorizationUrl([
        'scope' => 'rooms_manage' // Optional: specify scopes
    ]);

    // Get state and store it to the session
    $_SESSION['oauth2state'] = $provider->getState();

    // Redirect user to authorization URL
    header('Location: ' . $authorizationUrl);
    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 {
        // Try to get an access token using the authorization code grant
        $accessToken = $provider->getAccessToken('authorization_code', [
            'code' => $_GET['code']
        ]);

        // We have an access token, which we may use in authenticated
        // requests against the service provider's API.
        echo 'Access Token: ' . $accessToken->getToken() . "";
        echo 'Refresh Token: ' . $accessToken->getRefreshToken() . "";
        echo 'Expires: ' . $accessToken->getExpires() . "";
        echo 'Already expired? ' . ($accessToken->hasExpired() ? 'Yes' : 'No') . "";

        // Using the access token, get the user's details
        $resourceOwner = $provider->getResourceOwner($accessToken);

        // Show user ID
        var_dump($resourceOwner->getId());

        // Show all user data
        var_dump($resourceOwner->toArray());

    } catch (IdentityProviderException $e) {
        // Failed to get the access token or user details.
        exit($e->getMessage());
    }
}
```

### Refreshing a Token

[](#refreshing-a-token)

```
$refreshToken = $accessToken->getRefreshToken();

// Verify token has expired
if ($accessToken->hasExpired()) {
    $accessToken = $provider->getAccessToken('refresh_token', [
        'refresh_token' => $refreshToken
    ]);
}
```

### Making Authenticated API Requests

[](#making-authenticated-api-requests)

This package includes a helper method `executeRequest()` to easily make authenticated API requests:

```
try {
    // Make an authenticated API request
    $response = $provider->executeRequest(
        'GET',                // HTTP method
        '/endpoint',          // API endpoint
        $accessToken,         // Access token
        ['param' => 'value']  // Optional request body (will be JSON encoded)
    );

    // Process the response
    var_dump($response);

} catch (IdentityProviderException $e) {
    // Handle error
    echo $e->getMessage();
}
```

LockMe SDK and API Documentation
--------------------------------

[](#lockme-sdk-and-api-documentation)

### LockMe SDK

[](#lockme-sdk)

For more advanced integration with LockMe, we recommend using the [lustmored/lockme-sdk](https://github.com/lustmored/lockme-sdk) package. This SDK provides a more comprehensive set of features and utilities specifically designed for the LockMe API.

To install the LockMe SDK, use Composer:

```
composer require lustmored/lockme-sdk

```

For detailed documentation and usage examples, please refer to the [SDK repository](https://github.com/lustmored/lockme-sdk).

### API Documentation

[](#api-documentation)

For complete API specifications and endpoint documentation, please refer to the official [LockMe API Documentation](https://apidoc.lock.me/).

### Configuring the Provider

[](#configuring-the-provider)

The provider constructor accepts the following options:

```
$provider = new Lockme([
    'clientId'        => '{lockme-client-id}',      // Required
    'clientSecret'    => '{lockme-client-secret}',  // Required
    'redirectUri'     => 'https://example.com/',    // Required
    'apiDomain'       => 'https://api.lock.me',     // Optional: custom API domain
    'version'         => 'v2.1',                    // Optional: API version
    'ignoreSslErrors' => false                      // Optional: ignore SSL errors
]);
```

License
-------

[](#license)

This package is released under the GPL-3.0-or-later License. See the bundled [LICENSE](LICENSE) file for details.

###  Health Score

55

—

FairBetter than 97% of packages

Maintenance78

Regular maintenance activity

Popularity28

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 100% 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 ~150 days

Recently: every ~182 days

Total

20

Last Release

298d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/426c03afba39369e2dba2d3c2713c0831f26f02c405b8cfa23f0bf41b9ec2a91?d=identicon)[Lustmored](/maintainers/Lustmored)

---

Top Contributors

[![Lustmored](https://avatars.githubusercontent.com/u/2358046?v=4)](https://github.com/Lustmored "Lustmored (20 commits)")

### Embed Badge

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

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

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[thenetworg/oauth2-azure

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

25310.7M83](/packages/thenetworg-oauth2-azure)[league/oauth2-google

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

42223.4M176](/packages/league-oauth2-google)[stevenmaguire/oauth2-keycloak

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

2306.4M45](/packages/stevenmaguire-oauth2-keycloak)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[patrickbussmann/oauth2-apple

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

1152.8M12](/packages/patrickbussmann-oauth2-apple)

PHPackages © 2026

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