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

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

oliverschloebe/oauth2-rbtv
==========================

Rocket Beans TV OAuth 2.0 package for the PHP League's OAuth 2.0 Client

1.1.1(4y ago)325MITPHPPHP ^5.6 || ^7.0 || ^8.0

Since Jun 2Pushed 4y ago1 watchersCompare

[ Source](https://github.com/oliverschloebe/oauth2-rbtv)[ Packagist](https://packagist.org/packages/oliverschloebe/oauth2-rbtv)[ Fund](https://www.schloebe.de/donate/)[ RSS](/packages/oliverschloebe-oauth2-rbtv/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (6)Versions (3)Used By (0)

Rocket Beans TV Provider for OAuth 2.0 Client
=============================================

[](#rocket-beans-tv-provider-for-oauth-20-client)

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

[![CircleCI](https://camo.githubusercontent.com/47abc0385fb06dba3094c5a8c16300a78ccc4cef4ec195da8e566ae5b46819f5/68747470733a2f2f636972636c6563692e636f6d2f67682f6f6c697665727363686c6f6562652f6f61757468322d726274762f747265652f6d61737465722e7376673f7374796c653d737667)](https://circleci.com/gh/oliverschloebe/oauth2-rbtv/tree/master) [![Build Status](https://camo.githubusercontent.com/4e7a725685e549dcf4de6abcc16b3cfacea8059fca173931681ab06c20793767/68747470733a2f2f7472617669732d63692e636f6d2f6f6c697665727363686c6f6562652f6f61757468322d726274762e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/oliverschloebe/oauth2-rbtv)[![StyleCI](https://camo.githubusercontent.com/9727cec296e07ff66c7bb00062e1aa3b43306339859e5eae186e2b0773b35144/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3138393735303335362f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/189750356)[![License](https://camo.githubusercontent.com/6660cd072c9e4c9bcc0aa5cc858b629e5562b8d3d41a5da9566acc4d493632f5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6f6c697665727363686c6f6562652f6f61757468322d726274762e737667)](https://github.com/oliverschloebe/oauth2-rbtv/blob/master/LICENSE)[![Latest Stable Version](https://camo.githubusercontent.com/98888c711cfb1bb76e6642bf296072ffa48d61ac72f9dc62b3c31bf751845639/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6c697665727363686c6f6562652f6f61757468322d726274762e737667)](https://packagist.org/packages/oliverschloebe/oauth2-rbtv)[![Latest Version](https://camo.githubusercontent.com/a2448432fa63074c17df91b4b57ada08a139697e219b3b31f9d735176f52926d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6f6c697665727363686c6f6562652f6f61757468322d726274762e7376673f7374796c653d666c61742d737175617265)](https://github.com/oliverschloebe/oauth2-rbtv/releases)[![Source Code](https://camo.githubusercontent.com/21b05f13c9e7674151b143acafd7fc5c73ac3a760443e44bedbbbacdbc69ffb8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d6f6c697665727363686c6f6562652f6f61757468322d2d726274762d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/oliverschloebe/oauth2-rbtv)

---

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

[](#installation)

```
composer require oliverschloebe/oauth2-rbtv

```

Rocket Beans TV API
-------------------

[](#rocket-beans-tv-api)

Usage
-----

[](#usage)

[Register your apps on rocketbeans.tv](https://rocketbeans.tv/accountsettings/apps) to get `clientId` and `clientSecret`.

### OAuth2 Authentication Flow

[](#oauth2-authentication-flow)

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

//session_start(); // optional, depending on your used data store

$rbtvProvider = new \OliverSchloebe\OAuth2\Client\Provider\Rbtv([
	'clientId'	=> 'yourId',          // The client ID of your RBTV app
	'clientSecret'	=> 'yourSecret',      // The client password of your RBTV app
	'redirectUri'	=> 'yourRedirectUri'  // The return URL you specified for your app on RBTV
]);

// Get authorization code
if (!isset($_GET['code'])) {
	// Options are optional, scope defaults to ['user.info']
	$options = [ 'scope' => ['user.info', 'user.email.read', 'user.notification.list', 'user.notification.manage', 'user.subscription.manage', 'user.subscriptions.read', 'user.rbtvevent.read', 'user.rbtvevent.manage'] ];
	// Get authorization URL
	$authorizationUrl = $rbtvProvider->getAuthorizationUrl($options);

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

	// Redirect user to authorization URL
	header('Location: ' . $authorizationUrl);
	exit;
} elseif (empty($_GET['state']) || (isset($_SESSION['oauth2state']) && $_GET['state'] !== $_SESSION['oauth2state'])) { // Check for errors
	if (isset($_SESSION['oauth2state'])) {
		unset($_SESSION['oauth2state']);
	}
	exit('Invalid state');
} else {
	// Get access token
	try {
		$accessToken = $rbtvProvider->getAccessToken(
			'authorization_code',
			[
				'code' => $_GET['code']
			]
		);

		// We have an access token, which we may use in authenticated
		// requests against the RBTV API.
		echo 'Access Token: ' . $accessToken->getToken() . "";
		echo 'Refresh Token: ' . $accessToken->getRefreshToken() . "";
		echo 'Expired in: ' . $accessToken->getExpires() . "";
		echo 'Already expired? ' . ($accessToken->hasExpired() ? 'expired' : 'not expired') . "";
	} catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
		exit($e->getMessage());
	}

	// Get resource owner
	try {
		$resourceOwner = $rbtvProvider->getResourceOwner($accessToken);
	} catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
		exit($e->getMessage());
	}

	// Store the results to session or whatever
	$_SESSION['accessToken'] = $accessToken;
	$_SESSION['resourceOwner'] = $resourceOwner;

	var_dump(
		$resourceOwner->getId(),
		$resourceOwner->getName(),
		$resourceOwner->getEmail(),
		$resourceOwner->getAttribute('email'), // allows dot notation, e.g. $resourceOwner->getAttribute('group.field')
		$resourceOwner->toArray()
	);
}
```

### Refreshing a Token

[](#refreshing-a-token)

Once your application is authorized, you can refresh an expired token using a refresh token rather than going through the entire process of obtaining a brand new token. To do so, simply reuse this refresh token from your data store to request a refresh.

```
$rbtvProvider = new \OliverSchloebe\OAuth2\Client\Provider\Rbtv([
	'clientId'	=> 'yourId',          // The client ID of your RBTV app
	'clientSecret'	=> 'yourSecret',      // The client password of your RBTV app
	'redirectUri'	=> 'yourRedirectUri'  // The return URL you specified for your app on RBTV
]);

$existingAccessToken = getAccessTokenFromYourDataStore();

if ($existingAccessToken->hasExpired()) {
	$newAccessToken = $rbtvProvider->getAccessToken('refresh_token', [
		'refresh_token' => $existingAccessToken->getRefreshToken()
	]);

	// Purge old access token and store new access token to your data store.
}
```

### Sending authenticated API requests

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

The RBTV OAuth 2.0 provider provides a way to get an authenticated API request for the service, using the access token; it returns an object conforming to `Psr\Http\Message\RequestInterface`.

```
$subscriptionsRequest = $rbtvProvider->getAuthenticatedRequest(
	'GET',
	'https://api.rocketbeans.tv/v1/subscription/mysubscriptions', // see https://github.com/rocketbeans/rbtv-apidoc#list-all-subscriptions
	$accessToken
);

// Get parsed response of current authenticated user's subscriptions; returns array|mixed
$mySubscriptions = $rbtvProvider->getParsedResponse($subscriptionsRequest);

var_dump($mySubscriptions);
```

### Sending non-authenticated API requests

[](#sending-non-authenticated-api-requests)

Send a non-authenticated API request to public endpoints of the RBTV API; it returns an object conforming to `Psr\Http\Message\RequestInterface`.

```
$blogParams = [ 'limit' => 10 ];
$blogRequest = $rbtvProvider->getRequest(
	'GET',
	'https://api.rocketbeans.tv/v1/blog/preview/all?' . http_build_query($blogParams)
);

// Get parsed response of non-authenticated API request; returns array|mixed
$blogPosts = $rbtvProvider->getParsedResponse($blogRequest);

var_dump($blogPosts);
```

### Using a proxy

[](#using-a-proxy)

It is possible to use a proxy to debug HTTP calls made to RBTV. All you need to do is set the proxy and verify options when creating your RBTV OAuth2 instance. Make sure to enable SSL proxying in your proxy.

```
$rbtvProvider = new \OliverSchloebe\OAuth2\Client\Provider\Rbtv([
	'clientId'	=> 'yourId',          // The client ID of your RBTV app
	'clientSecret'	=> 'yourSecret',      // The client password of your RBTV app
	'redirectUri'	=> 'yourRedirectUri'  // The return URL you specified for your app on RBTV
	'proxy'		=> '192.168.0.1:8888',
	'verify'	=> false
]);
```

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

[](#requirements)

PHP 5.6 or higher.

Testing
-------

[](#testing)

```
$ ./vendor/bin/parallel-lint src test
$ ./vendor/bin/phpunit --coverage-text
$ ./vendor/bin/phpcs src --standard=psr2 -sp
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/oliverschloebe/oauth2-rbtv/blob/master/LICENSE) for more information.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

Established project with proven stability

 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 ~920 days

Total

2

Last Release

1614d ago

PHP version history (2 changes)1.1.0PHP ^5.6|^7.0

1.1.1PHP ^5.6 || ^7.0 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/111d5154eea89c672a6024cacaefd8260f7541601960993940e0b3cf9c0ca5a7?d=identicon)[cyberblitzbirne](/maintainers/cyberblitzbirne)

---

Top Contributors

[![oliverschloebe](https://avatars.githubusercontent.com/u/82846?v=4)](https://github.com/oliverschloebe "oliverschloebe (39 commits)")

---

Tags

authorisationauthorizationclientoauthoauth2oauth2-providerrbtvphpapiclientSSOidentityoauthoauth2authorizationidpsingle sign onauthorisationrbtv

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[adam-paterson/oauth2-stripe

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

172.4M4](/packages/adam-paterson-oauth2-stripe)[brenoroosevelt/oauth2-govbr

Cliente OAuth2 para Gov.br

2011.0k](/packages/brenoroosevelt-oauth2-govbr)

PHPackages © 2026

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