{"id":22725207,"url":"https://github.com/oliverschloebe/oauth2-rbtv","last_synced_at":"2026-01-23T16:36:27.289Z","repository":{"id":45555165,"uuid":"189750356","full_name":"oliverschloebe/oauth2-rbtv","owner":"oliverschloebe","description":"Rocket Beans TV Provider for OAuth 2.0 Client","archived":false,"fork":false,"pushed_at":"2021-12-09T17:52:29.000Z","size":50,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-04T13:46:46.665Z","etag":null,"topics":["authorisation","authorization","client","oauth","oauth2","oauth2-provider","rbtv"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oliverschloebe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"custom":["https://www.schloebe.de/donate/"]}},"created_at":"2019-06-01T15:45:57.000Z","updated_at":"2021-12-09T17:52:32.000Z","dependencies_parsed_at":"2022-08-27T18:20:36.298Z","dependency_job_id":null,"html_url":"https://github.com/oliverschloebe/oauth2-rbtv","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliverschloebe%2Foauth2-rbtv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliverschloebe%2Foauth2-rbtv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliverschloebe%2Foauth2-rbtv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliverschloebe%2Foauth2-rbtv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oliverschloebe","download_url":"https://codeload.github.com/oliverschloebe/oauth2-rbtv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229082285,"owners_count":18017251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authorisation","authorization","client","oauth","oauth2","oauth2-provider","rbtv"],"created_at":"2024-12-10T15:10:14.318Z","updated_at":"2026-01-23T16:36:27.276Z","avatar_url":"https://github.com/oliverschloebe.png","language":"PHP","funding_links":["https://www.schloebe.de/donate/"],"categories":[],"sub_categories":[],"readme":"# Rocket Beans TV Provider for OAuth 2.0 Client\n\nThis package provides Rocket Beans TV OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).\n\n[![CircleCI](https://circleci.com/gh/oliverschloebe/oauth2-rbtv/tree/master.svg?style=svg)](https://circleci.com/gh/oliverschloebe/oauth2-rbtv/tree/master) [![Build Status](https://travis-ci.com/oliverschloebe/oauth2-rbtv.svg?branch=master)](https://travis-ci.com/oliverschloebe/oauth2-rbtv)\n[![StyleCI](https://github.styleci.io/repos/189750356/shield?branch=master)](https://github.styleci.io/repos/189750356)\n[![License](https://img.shields.io/packagist/l/oliverschloebe/oauth2-rbtv.svg)](https://github.com/oliverschloebe/oauth2-rbtv/blob/master/LICENSE)\n[![Latest Stable Version](https://img.shields.io/packagist/v/oliverschloebe/oauth2-rbtv.svg)](https://packagist.org/packages/oliverschloebe/oauth2-rbtv)\n[![Latest Version](https://img.shields.io/github/release/oliverschloebe/oauth2-rbtv.svg?style=flat-square)](https://github.com/oliverschloebe/oauth2-rbtv/releases)\n[![Source Code](https://img.shields.io/badge/source-oliverschloebe/oauth2--rbtv-blue.svg?style=flat-square)](https://github.com/oliverschloebe/oauth2-rbtv)\n\n---\n\n## Installation\n\n```\ncomposer require oliverschloebe/oauth2-rbtv\n```\n\n## Rocket Beans TV API\n\nhttps://github.com/rocketbeans/rbtv-apidoc\n\n## Usage\n\n[Register your apps on rocketbeans.tv](https://rocketbeans.tv/accountsettings/apps) to get `clientId` and `clientSecret`.\n\n### OAuth2 Authentication Flow\n\n```php\nrequire_once __DIR__ . '/vendor/autoload.php';\n\n//session_start(); // optional, depending on your used data store\n\n$rbtvProvider = new \\OliverSchloebe\\OAuth2\\Client\\Provider\\Rbtv([\n\t'clientId'\t=\u003e 'yourId',          // The client ID of your RBTV app\n\t'clientSecret'\t=\u003e 'yourSecret',      // The client password of your RBTV app\n\t'redirectUri'\t=\u003e 'yourRedirectUri'  // The return URL you specified for your app on RBTV\n]);\n\n// Get authorization code\nif (!isset($_GET['code'])) {\n\t// Options are optional, scope defaults to ['user.info']\n\t$options = [ 'scope' =\u003e ['user.info', 'user.email.read', 'user.notification.list', 'user.notification.manage', 'user.subscription.manage', 'user.subscriptions.read', 'user.rbtvevent.read', 'user.rbtvevent.manage'] ];\n\t// Get authorization URL\n\t$authorizationUrl = $rbtvProvider-\u003egetAuthorizationUrl($options);\n\n\t// Get state and store it to the session\n\t$_SESSION['oauth2state'] = $rbtvProvider-\u003egetState();\n\n\t// Redirect user to authorization URL\n\theader('Location: ' . $authorizationUrl);\n\texit;\n} elseif (empty($_GET['state']) || (isset($_SESSION['oauth2state']) \u0026\u0026 $_GET['state'] !== $_SESSION['oauth2state'])) { // Check for errors\n\tif (isset($_SESSION['oauth2state'])) {\n\t\tunset($_SESSION['oauth2state']);\n\t}\n\texit('Invalid state');\n} else {\n\t// Get access token\n\ttry {\n\t\t$accessToken = $rbtvProvider-\u003egetAccessToken(\n\t\t\t'authorization_code',\n\t\t\t[\n\t\t\t\t'code' =\u003e $_GET['code']\n\t\t\t]\n\t\t);\n\t\t\n\t\t// We have an access token, which we may use in authenticated\n\t\t// requests against the RBTV API.\n\t\techo 'Access Token: ' . $accessToken-\u003egetToken() . \"\u003cbr /\u003e\";\n\t\techo 'Refresh Token: ' . $accessToken-\u003egetRefreshToken() . \"\u003cbr /\u003e\";\n\t\techo 'Expired in: ' . $accessToken-\u003egetExpires() . \"\u003cbr /\u003e\";\n\t\techo 'Already expired? ' . ($accessToken-\u003ehasExpired() ? 'expired' : 'not expired') . \"\u003cbr /\u003e\";\n\t} catch (\\League\\OAuth2\\Client\\Provider\\Exception\\IdentityProviderException $e) {\n\t\texit($e-\u003egetMessage());\n\t}\n\n\t// Get resource owner\n\ttry {\n\t\t$resourceOwner = $rbtvProvider-\u003egetResourceOwner($accessToken);\n\t} catch (\\League\\OAuth2\\Client\\Provider\\Exception\\IdentityProviderException $e) {\n\t\texit($e-\u003egetMessage());\n\t}\n        \n\t// Store the results to session or whatever\n\t$_SESSION['accessToken'] = $accessToken;\n\t$_SESSION['resourceOwner'] = $resourceOwner;\n    \n\tvar_dump(\n\t\t$resourceOwner-\u003egetId(),\n\t\t$resourceOwner-\u003egetName(),\n\t\t$resourceOwner-\u003egetEmail(),\n\t\t$resourceOwner-\u003egetAttribute('email'), // allows dot notation, e.g. $resourceOwner-\u003egetAttribute('group.field')\n\t\t$resourceOwner-\u003etoArray()\n\t);\n}\n```\n\n### Refreshing a Token\n\nOnce 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.\n\n```php\n$rbtvProvider = new \\OliverSchloebe\\OAuth2\\Client\\Provider\\Rbtv([\n\t'clientId'\t=\u003e 'yourId',          // The client ID of your RBTV app\n\t'clientSecret'\t=\u003e 'yourSecret',      // The client password of your RBTV app\n\t'redirectUri'\t=\u003e 'yourRedirectUri'  // The return URL you specified for your app on RBTV\n]);\n\n$existingAccessToken = getAccessTokenFromYourDataStore();\n\nif ($existingAccessToken-\u003ehasExpired()) {\n\t$newAccessToken = $rbtvProvider-\u003egetAccessToken('refresh_token', [\n\t\t'refresh_token' =\u003e $existingAccessToken-\u003egetRefreshToken()\n\t]);\n\n\t// Purge old access token and store new access token to your data store.\n}\n```\n\n### Sending authenticated API requests\n\nThe 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`.\n\n```php\n$subscriptionsRequest = $rbtvProvider-\u003egetAuthenticatedRequest(\n\t'GET',\n\t'https://api.rocketbeans.tv/v1/subscription/mysubscriptions', // see https://github.com/rocketbeans/rbtv-apidoc#list-all-subscriptions\n\t$accessToken\n);\n\n// Get parsed response of current authenticated user's subscriptions; returns array|mixed\n$mySubscriptions = $rbtvProvider-\u003egetParsedResponse($subscriptionsRequest);\n\nvar_dump($mySubscriptions);\n```\n\n### Sending non-authenticated API requests\n\nSend a non-authenticated API request to public endpoints of the RBTV API; it returns an object conforming to `Psr\\Http\\Message\\RequestInterface`.\n\n```php\n$blogParams = [ 'limit' =\u003e 10 ];\n$blogRequest = $rbtvProvider-\u003egetRequest(\n\t'GET',\n\t'https://api.rocketbeans.tv/v1/blog/preview/all?' . http_build_query($blogParams)\n);\n\n// Get parsed response of non-authenticated API request; returns array|mixed\n$blogPosts = $rbtvProvider-\u003egetParsedResponse($blogRequest);\n\nvar_dump($blogPosts);\n```\n\n### Using a proxy\n\nIt 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.\n\n```php\n$rbtvProvider = new \\OliverSchloebe\\OAuth2\\Client\\Provider\\Rbtv([\n\t'clientId'\t=\u003e 'yourId',          // The client ID of your RBTV app\n\t'clientSecret'\t=\u003e 'yourSecret',      // The client password of your RBTV app\n\t'redirectUri'\t=\u003e 'yourRedirectUri'  // The return URL you specified for your app on RBTV\n\t'proxy'\t\t=\u003e '192.168.0.1:8888',\n\t'verify'\t=\u003e false\n]);\n```\n\n## Requirements\n\nPHP 5.6 or higher.\n\n## Testing\n\n``` bash\n$ ./vendor/bin/parallel-lint src test\n$ ./vendor/bin/phpunit --coverage-text\n$ ./vendor/bin/phpcs src --standard=psr2 -sp\n```\n\n## License\n\nThe MIT License (MIT). Please see [License File](https://github.com/oliverschloebe/oauth2-rbtv/blob/master/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foliverschloebe%2Foauth2-rbtv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foliverschloebe%2Foauth2-rbtv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foliverschloebe%2Foauth2-rbtv/lists"}