{"id":13556884,"url":"https://github.com/xrelease/oauth2-xrel","last_synced_at":"2026-04-03T08:40:22.307Z","repository":{"id":57084941,"uuid":"55868048","full_name":"xrelease/oauth2-xrel","owner":"xrelease","description":"xREL OAuth 2.0 Client Provider for The PHP League OAuth2-Client http://oauth2-client.thephpleague.com/","archived":false,"fork":false,"pushed_at":"2016-04-11T13:04:52.000Z","size":8,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-04T06:35:22.736Z","etag":null,"topics":[],"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/xrelease.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-09T21:36:15.000Z","updated_at":"2020-08-02T21:41:25.000Z","dependencies_parsed_at":"2022-08-24T22:50:53.527Z","dependency_job_id":null,"html_url":"https://github.com/xrelease/oauth2-xrel","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/xrelease%2Foauth2-xrel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xrelease%2Foauth2-xrel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xrelease%2Foauth2-xrel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xrelease%2Foauth2-xrel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xrelease","download_url":"https://codeload.github.com/xrelease/oauth2-xrel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246984635,"owners_count":20864481,"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":[],"created_at":"2024-08-01T12:04:04.120Z","updated_at":"2025-12-12T18:53:46.239Z","avatar_url":"https://github.com/xrelease.png","language":"PHP","funding_links":[],"categories":["PHP","others"],"sub_categories":[],"readme":"# xREL Provider for OAuth 2.0 Client\n[![Latest Version](https://img.shields.io/github/release/xrelease/oauth2-xrel.svg?style=flat-square)](https://github.com/xrelease/oauth2-xrel/releases)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n[![Build Status](https://scrutinizer-ci.com/g/xrelease/oauth2-xrel/badges/build.png?b=master)](https://scrutinizer-ci.com/g/xrelease/oauth2-xrel/build-status/master)\n[![HHVM Status](https://img.shields.io/hhvm/xrelease/oauth2-xrel.svg?style=flat-square)](http://hhvm.h4cc.de/package/xrelease/oauth2-xrel)\n[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/xrelease/oauth2-xrel.svg?style=flat-square)](https://scrutinizer-ci.com/g/xrelease/oauth2-xrel/code-structure)\n[![Quality Score](https://img.shields.io/scrutinizer/g/xrelease/oauth2-xrel.svg?style=flat-square)](https://scrutinizer-ci.com/g/xrelease/oauth2-xrel)\n[![Dependency Status](https://www.versioneye.com/user/projects/570a2acafcd19a0039f16a1a/badge.svg?style=flat)](https://www.versioneye.com/php/xrelease:oauth2-xrel/1.0.0)\n\nThis package provides xREL OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).\n\n## Installation\n\nTo install, use composer:\n\n```\ncomposer require xrelease/oauth2-xrel\n```\n\n## Usage\n\nUsage is the same as The League's OAuth client, using `\\xREL\\OAuth2\\Client\\Provider\\xREL` as the provider.\n\n### Authorization Code Flow\n\n```php\n\u003c?php\n$provider = new \\xREL\\OAuth2\\Client\\Provider\\xREL([\n    'clientId'          =\u003e '{xrel-client-id}',\n    'clientSecret'      =\u003e '{xrel-client-secret}',\n    'redirectUri'       =\u003e 'https://example.com/callback-url',\n]);\n\nif (!isset($_GET['code'])) {\n\n    // If we don't have an authorization code then get one\n    $authUrl = $provider-\u003egetAuthorizationUrl();\n    $_SESSION['oauth2state'] = $provider-\u003egetState();\n    header('Location: '.$authUrl);\n    exit;\n\n// Check given state against previously stored one to mitigate CSRF attack\n} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {\n\n    unset($_SESSION['oauth2state']);\n    exit('Invalid state');\n\n} else {\n\n    // Try to get an access token (using the authorization code grant)\n    $token = $provider-\u003egetAccessToken('authorization_code', [\n        'code' =\u003e $_GET['code']\n    ]);\n\n    // Optional: Now you have a token you can look up a users profile data\n    try {\n\n        // We got an access token, let's now get the user's details\n        $user = $provider-\u003egetResourceOwner($token);\n\n        // Use these details to create a new profile\n        printf('Hello %s!', $user-\u003egetName());\n\n    } catch (Exception $e) {\n\n        // Failed to get user details\n        exit('Oh dear...');\n    }\n\n    // Use this to interact with an API on the users behalf\n    echo $token-\u003egetToken();\n}\n```\n\n## Testing\n\n``` bash\n$ ./vendor/bin/phpunit\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/xrelease/oauth2-xrel/blob/master/CONTRIBUTING.md) for details.\n\n\n## Credits\n\n- [xREL](https://github.com/xrelease)\n- [All Contributors](https://github.com/xrelease/oauth2-xrel/contributors)\n\n\n## License\n\nThe MIT License (MIT). Please see [License File](https://github.com/xrelease/oauth2-xrel/blob/master/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxrelease%2Foauth2-xrel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxrelease%2Foauth2-xrel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxrelease%2Foauth2-xrel/lists"}