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

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

pandaac/oauth2-otland
=====================

021PHP

Since Aug 23Pushed 9y ago1 watchersCompare

[ Source](https://github.com/pandaac/oauth2-otland)[ Packagist](https://packagist.org/packages/pandaac/oauth2-otland)[ RSS](/packages/pandaac-oauth2-otland/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![Abandoned](https://raw.githubusercontent.com/eklundchristopher/resources/master/abandoned/abandoned.png)](https://raw.githubusercontent.com/eklundchristopher/resources/master/abandoned/abandoned.png)

OAuth2 Client for OtLand.net
============================

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

This package allows your site users to authenticate themselves through their OtLand.net account, which in turn returns an object with their OtLand details for you to do which what you see fit.

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

[](#requirements)

- PHP 5.5.9+
- OtLand client credentials
    - The only way to receive your own client ID &amp; secret is by sending [@Mark](https://otland.net/members/mark.1/) a private message requesting it. You will have to provide him with a project name, a short description of it, as well as a redirect URI. It is then up to him whether you'll be granted the necessary credentials or not.

Install
-------

[](#install)

##### Via Composer

[](#via-composer)

```
composer require pandaac/oauth2-otland

```

OAuth2 Options
--------------

[](#oauth2-options)

When instantiating the `pandaac\OAuth2OtLand\Providers\OtLand` object, you may pass an array of options as its first argument.

- **Client ID *(required)***
    Assign your Client ID to the `clientId` key.
- **Client Secret *(required)***
    Assign your Client Secret to the `clientSecret` key.
- **Redirect URI *(required)***
    Assign your Redirect URI to the `redirectUri` key.
- **Scopes**
    Assign your scopes as an array to the `scope` key. It defaults to `['read']`.

> *The API that OtLand.net uses is [bdApi](https://github.com/xfrocks/bdApi/blob/master/docs/api.markdown). Please refer to their documentation for anything beyond simple authorization.*

Examples
--------

[](#examples)

##### Laravel 5.x

[](#laravel-5x)

Add the OtLand OAuth2 client service provider to the service providers array in `./config/app.php`.

```
pandaac\OAuth2OtLand\FrameworkIntegration\Laravel\OtLandOAuth2ServiceProvider::class
```

You should then publish the package configuration files by running the following artisan command.

```
php artisan vendor:publish --provider="pandaac\OAuth2OtLand\FrameworkIntegration\Laravel\OtLandOAuth2ServiceProvider"

```

> *You may edit your OAuth2 credentials directly in `./config/oauth2-otland.php`, although it is strongly recommended to do so through your `.env` file instead (`OTLAND_KEY`, `OTLAND_SECRET` &amp; `OTLAND_REDIRECT`).*

and finally define a route similiar to that as shown below

```
use Illuminate\Http\Request;
use pandaac\OAuth2OtLand\Providers\OtLand;

$router->get('/otland', function (Request $request) {
    try {

        $otland = app(OtLand::class);

        // Redirect the user to the authorization url if no code was provided
        if (! $request->has('code')) {
            $url = $otland->getAuthorizationUrl();

            $request->session()->put('oauth2state', $otland->getState());

            return redirect($url);
        }

        // If the state is invalid, redirect the user
        if (! $request->has('state') or ($request->get('state') !== $request->session()->get('oauth2state'))) {
            $request->session()->forget('oauth2state');

            return redirect('/');
        }

        $accessToken = $otland->getAccessToken('authorization_code', [
            'code' => $request->get('code')
        ]);

        $owner = $otland->getResourceOwner($accessToken);

        dd($owner->toArray());

    } catch (Exception $e) {
        // Log errors...
    }
});
```

##### No framework

[](#no-framework)

```
use pandaac\OAuth2OtLand\Providers\OtLand;

session_start();

try {

    $otland = new OtLand([
        'clientId'      => 'MY-CLIENT-ID',
        'clientSecret'  => 'MY-CLIENT-SECRET',
        'redirectUri'   => 'MY-REDIRECT-URI',
    ]);

    // Redirect the user to the authorization url if no code was provided
    if (! isset($_GET['code'])) {
        $url = $otland->getAuthorizationUrl();

        $_SESSION['oauth2state'] = $otland->getState();

        header('Location: '.$url);
        exit;
    }

    // If the state is invalid, redirect the user
    if (! isset($_GET['state']) or ($_GET['state'] !== $_SESSION['oauth2state'])) {
        unset($_SESSION['oauth2state']);

        header('Location: /');
        exit;
    }

    $accessToken = $otland->getAccessToken('authorization_code', [
        'code' => $_GET['code']
    ]);

    $owner = $otland->getResourceOwner($accessToken);

    var_dump($owner->toArray());

} catch (Exception $e) {
    // Log errors...
}
```

Contributing
------------

[](#contributing)

Please refer to the [PSR-2 guidelines](http://www.php-fig.org/psr/psr-2/) and squash your commits together into one before submitting a pull request.

Thank you.

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community5

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/280eafadc6af3f5226043e5add75ce5b251d98e4f26cac7e667eb3bfdd8726df?d=identicon)[eklundchristopher](/maintainers/eklundchristopher)

### Embed Badge

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

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

###  Alternatives

[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

761.2M17](/packages/kartik-v-yii2-password)

PHPackages © 2026

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