{"id":13669223,"url":"https://github.com/AlloVince/EvaOAuth","last_synced_at":"2025-04-27T01:32:54.199Z","repository":{"id":11429686,"uuid":"13883089","full_name":"AlloVince/EvaOAuth","owner":"AlloVince","description":"EvaOAuth provides a standard interface for OAuth1.0(a) / OAuth2.0 client authorization, it is easy to integrate with any PHP project by very few lines code. ","archived":false,"fork":false,"pushed_at":"2019-04-02T09:45:37.000Z","size":523,"stargazers_count":251,"open_issues_count":3,"forks_count":66,"subscribers_count":24,"default_branch":"master","last_synced_at":"2024-12-01T20:48:36.097Z","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":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlloVince.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-26T12:31:51.000Z","updated_at":"2024-11-29T03:03:58.000Z","dependencies_parsed_at":"2022-08-25T19:20:46.934Z","dependency_job_id":null,"html_url":"https://github.com/AlloVince/EvaOAuth","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlloVince%2FEvaOAuth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlloVince%2FEvaOAuth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlloVince%2FEvaOAuth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlloVince%2FEvaOAuth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlloVince","download_url":"https://codeload.github.com/AlloVince/EvaOAuth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251077102,"owners_count":21532607,"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-02T08:01:06.733Z","updated_at":"2025-04-27T01:32:51.440Z","avatar_url":"https://github.com/AlloVince.png","language":"PHP","funding_links":[],"categories":["PHP","身份验证( Authentication and Authorization )","身份验证和授权 Authentication and Authorization"],"sub_categories":[],"readme":"EvaOAuth\n=========\n\n[![Latest Stable Version](https://poser.pugx.org/evaengine/eva-oauth/v/stable.svg)](https://packagist.org/packages/evaengine/eva-oauth)\n[![License](https://poser.pugx.org/evaengine/eva-oauth/license.svg)](https://packagist.org/packages/evaengine/eva-oauth)\n[![Build Status](https://travis-ci.org/AlloVince/EvaOAuth.svg?branch=feature%2Frefactoring)](https://travis-ci.org/AlloVince/EvaOAuth)\n[![Coverage Status](https://coveralls.io/repos/AlloVince/EvaOAuth/badge.svg?branch=master)](https://coveralls.io/r/AlloVince/EvaOAuth?branch=master)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/AlloVince/EvaOAuth/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/AlloVince/EvaOAuth/?branch=master)\n\nEvaOAuth provides a standard interface for OAuth1.0 / OAuth2.0 client authorization, it is easy to integrate with any PHP project by very few lines code. \n\n[中文文档](http://avnpc.com/pages/evaoauth)\n\n## Features\n\n- **Standard interface**, same code for both OAuth1.0 and OAuth2.0 different workflow, receiving token and user info as same format either.  \n- **Fully tested** \n- **Easy to debug**, enable debug mode will record every request and response, help you find out problems quickly.\n- **Out-of-the-box**, already supported most popular websites including Facebook. Twitter, etc.\n- **Scalable**, integrate a new oauth website just need 3 lines code.\n\n## Quick Start\n\nEvaOAuth can be found on [Packagist](https://packagist.org/packages/evaengine/eva-oauth). The recommended way to install this is through composer.\n\nEdit your composer.json and add:\n\n``` json\n{\n    \"require\": {\n        \"evaengine/eva-oauth\": \"~1.0\"\n    }\n}\n```\n\nAnd install dependencies:\n\n``` shell\ncurl -sS https://getcomposer.org/installer | php\nphp composer.phar install\n```\n\nLet's start a example of Facebook Login, if you have already have a Facebook developer account and created an app, prepare a request.php as below: \n\n``` php\n$service = new Eva\\EvaOAuth\\Service('Facebook', [\n    'key' =\u003e 'You Facebook App ID',\n    'secret' =\u003e 'You Facebook App Secret',\n    'callback' =\u003e 'http://localhost/EvaOAuth/example/access.php'\n]);\n$service-\u003erequestAuthorize();\n```\n\nRun request.php in browser, will be redirected to Facebook authorization page. After user confirm authorization, prepare the access.php for callback:\n\n``` php\n$token = $service-\u003egetAccessToken();\n```\n\nOnce access token received, we could use access token to visit any protected resources.\n\n``` php\n$httpClient = new Eva\\EvaOAuth\\AuthorizedHttpClient($token);\n$response = $httpClient-\u003eget('https://graph.facebook.com/me');\n```\n \nThat's it, more usages please check [examples](https://github.com/AlloVince/EvaOAuth/tree/master/examples) and [wiki](https://github.com/AlloVince/EvaOAuth/wiki).\n\n## Providers\n\nEvaOAuth supports most popular OAuth services as below:\n\n- OAuth2.0\n  - Douban\n  - Facebook\n  - Tencent\n  - Weibo\n- OAuth1.0\n  - Twitter\n  \nCreating a custom provider require only few lines code, for OAuth2 sites:\n\n\n``` php\nnamespace YourNamespace;\n\nclass Foursquare extends \\Eva\\EvaOAuth\\OAuth2\\Providers\\AbstractProvider\n{\n    protected $authorizeUrl = 'https://foursquare.com/oauth2/authorize';\n    protected $accessTokenUrl = 'https://foursquare.com/oauth2/access_token';\n}\n```\n\nThen register to service and create instance:\n\n``` php\nuse Eva\\EvaOAuth\\Service;\nService::registerProvider('foursquare', 'YourNamespace\\Foursquare');\n$service = new Service('foursquare', [\n    'key' =\u003e 'Foursquare App ID',\n    'secret' =\u003e 'Foursquare App Secret',\n    'callback' =\u003e 'http://somecallback/'\n]);\n```\n\n## Storage\n\nIn OAuth1.0 workflow, we need to store request token somewhere, and use request token exchange for access token.\n\nEvaOAuth use [Doctrine\\Cache](https://github.com/doctrine/cache) as storage layer. If no configuration, default storage layer use file system to save data, default path is EvaOAuth/tmp.\n \nFeel free to change file storage path before `Service` start:\n\n``` php\nService::setStorage(new Doctrine\\Common\\Cache\\FilesystemCache('/tmp'));\n```\n\nOr use other storage such as Memcache:\n\n``` php\n$storage = new \\Doctrine\\Common\\Cache\\MemcacheCache();\n$storage-\u003esetMemcache(new \\Memcache());\nService::setStorage($storage);\n```\n\n## Events Support\n\nEvaOAuth defined some events for easier injection which are:\n\n- BeforeGetRequestToken: Triggered before get request token.\n- BeforeAuthorize: Triggered before redirect to authorize page.\n- BeforeGetAccessToken: Triggered before get access token.\n\nFor example, if we want to send an additional header before get access token:\n\n``` php\n$service-\u003egetEmitter()-\u003eon('beforeGetAccessToken', function(\\Eva\\EvaOAuth\\Events\\BeforeGetAccessToken $event) {\n    $event-\u003egetRequest()-\u003eaddHeader('foo', 'bar');\n});\n```\n\n## Implementation Specification\n\nEvaOAuth based on amazing http client library [Guzzle](https://github.com/guzzle/guzzle), use fully OOP to describe OAuth specification.\n\nRefer wiki for details:\n \n- [OAuth1.0](https://github.com/AlloVince/EvaOAuth/wiki/OAuth1.0-Specification-Implementation)\n- [OAuth2.0](https://github.com/AlloVince/EvaOAuth/wiki/OAuth2.0-Specification-Implementation)\n\n## Debug and Logging\n\nEnable debug mode will log all requests \u0026 responses.\n\n``` php\n$service-\u003edebug('/tmp/access.log');\n```\n\nMake sure PHP script have permission to write log path.\n\n\n## API References\n\nRun `phpdoc` will generate API references under `docs/`.\n\n![](https://avnpc.com/static/images/telegram.png)\n\n[Join My Telegram Group](https://t.me/joinchat/HKvcQAw2kqASoYfxiSrIbA)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAlloVince%2FEvaOAuth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAlloVince%2FEvaOAuth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAlloVince%2FEvaOAuth/lists"}