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

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

fruitcake/oauth2-rooiontmoet
============================

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

04PHP

Since Feb 25Pushed 10y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

RooiOntmoet Provider for OAuth 2.0 Client
=========================================

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

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

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

[](#requirements)

- PHP 5.5 or higher

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

[](#installation)

Require this package with Composer:

```
composer require fruitcake/oauth2-rooiontmoet:"~1.0@dev"

```

> During development, the `@dev` flag is required.

Usage
-----

[](#usage)

### Available Scopes

[](#available-scopes)

- profile: Default public profile (full name + ID)
- email: The user email

You will need to apply for API access. By default, only `profile` access is granted. Admin users can have access to more scopes, depending on the access level. Contact Fruitcake for more information.

> Only verified endpoints have access, so make sure you register those first!

### Authorization Code Flow

[](#authorization-code-flow)

```
require __DIR__ .'/../vendor/autoload.php';

session_start();

// Create Provider
$provider = new RooiOntmoet\OAuth2\Client\Provider\RooiOntmoet([
  'clientId'          => 'my-client-id',
  'clientSecret'      => 'my-client-secret',
  'redirectUri'       => 'http://my-domain.com/login-callback.php',
]);

if (!isset($_GET['code'])) {

    // If we don't have an authorization code then get one
    $authUrl = $provider->getAuthorizationUrl([
      'scope' => ['profile', 'email']
    ]);

    $_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->getName());

        echo '';

        // Use this to save the user information
        print_r($user->toArray());

        // Use this to interact with an API on the users behalf
        var_dump($token->getToken());
        # string(217) "CAADAppfn3msBAI7tZBLWg...

        // Number of seconds until the access token will expire, and need refreshing
        var_dump($token->getExpires());
        # int(1436825866)

        echo '';
    } catch (Exception $e) {

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

}
```

### The RooiOntmoetUser Entity

[](#the-rooiontmoetuser-entity)

When using the `getResourceOwner()` method to obtain the user node, it will be returned as a `RooiOntmoetUser` entity.

```
$user = $provider->getResourceOwner($token);

$id = $user->getId();
var_dump($id);
# string(1) "4"

$name = $user->getName();
var_dump($name);
# string(15) "First Last"

# Requires the "email" scope
$email = $user->getEmail();
var_dump($email);
# string(15) "user@example.com"
```

You can also get all the data from the User node as a plain-old PHP array with `toArray()`.

```
$userData = $user->toArray();
```

### Client Credentials Flow

[](#client-credentials-flow)

You can use the Client Credentials Flow to make a direct request within your application, without asking for permission. This will operate on behalf of your own Client and is only available when you have access to the given scopes.

```
// Create Provider
$provider = new RooiOntmoet\OAuth2\Client\Provider\RooiOntmoet([
  'clientId' => 'my-client-id',
  'clientSecret' => 'my-client-secret',
]);

try {
    // Try to get an access token using the client credentials grant.
    $token = $provider->getAccessToken('client_credentials', [
      'scope' => 'allusers',
    ]);

    $request = $provider->getAuthenticatedRequest('GET', $provider->baseResourceUrl . '/users', $token);
    $response = $provider->getHttpClient()->send($request);
    $result = json_decode($response->getBody(), true);

    dd($result);

} catch (\Exception $e) {

    // Failed to get the access token
    exit($e->getMessage());

}
```

### Laravel Socialite Driver

[](#laravel-socialite-driver)

You can use the Socialite provider to enable easy OAuth in Laravel. Just add the driver in your ServiceProvider.

```
$socialite = $this->app->make('Laravel\Socialite\Contracts\Factory');
$socialite->extend(
    'rooiontmoet',
    function ($app) use ($socialite) {
        $config = [
              'client_id' => 'client1id',
              'client_secret' => 'client1secret',
              'redirect' => '',
          ];

        $provider = $socialite->buildProvider('RooiOntmoet\OAuth2\Client\Socialite\RooiOntmoet', $config);
        $provider = $provider->scopes(['public', 'email']);

        return $provider;
    }
);
```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/dad47b02be23edb7094a151b4b1ce7e9cb56b75cd87cd3341d140e1e1e9cd0e4?d=identicon)[barryvdh](/maintainers/barryvdh)

---

Top Contributors

[![barryvdh](https://avatars.githubusercontent.com/u/973269?v=4)](https://github.com/barryvdh "barryvdh (4 commits)")[![robinvalk](https://avatars.githubusercontent.com/u/3050565?v=4)](https://github.com/robinvalk "robinvalk (1 commits)")

### Embed Badge

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

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

###  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)
