{"id":15524555,"url":"https://github.com/adoy/php-oauth2","last_synced_at":"2025-04-14T08:53:43.945Z","repository":{"id":41394732,"uuid":"1621238","full_name":"adoy/PHP-OAuth2","owner":"adoy","description":"Light PHP wrapper for the OAuth 2.0 protocol (based on OAuth 2.0 Authorization Protocol draft-ietf-oauth-v2-15)","archived":false,"fork":false,"pushed_at":"2024-04-11T13:42:10.000Z","size":75,"stargazers_count":391,"open_issues_count":29,"forks_count":152,"subscribers_count":34,"default_branch":"master","last_synced_at":"2025-04-07T01:09:06.494Z","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":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adoy.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-04-15T22:53:39.000Z","updated_at":"2025-02-21T19:13:13.000Z","dependencies_parsed_at":"2024-06-18T11:00:36.678Z","dependency_job_id":"789e4579-3b73-4591-8dc8-cfe2a69f7f2e","html_url":"https://github.com/adoy/PHP-OAuth2","commit_stats":{"total_commits":63,"total_committers":18,"mean_commits":3.5,"dds":"0.47619047619047616","last_synced_commit":"2f28fc76ad5ad6974333eaf84a3d05164f2ed586"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adoy%2FPHP-OAuth2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adoy%2FPHP-OAuth2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adoy%2FPHP-OAuth2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adoy%2FPHP-OAuth2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adoy","download_url":"https://codeload.github.com/adoy/PHP-OAuth2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248852108,"owners_count":21171839,"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-10-02T10:51:41.473Z","updated_at":"2025-04-14T08:53:43.919Z","avatar_url":"https://github.com/adoy.png","language":"PHP","readme":"# Light PHP wrapper for the OAuth 2.0\n\n[![Latest Stable Version](https://poser.pugx.org/adoy/fastcgi-client/v/stable)](https://packagist.org/packages/adoy/fastcgi-client)\n[![GitHub](https://img.shields.io/github/license/adoy/PHP-OAuth2)](LICENSE)\n[![Total Downloads](https://poser.pugx.org/adoy/fastcgi-client/downloads)](https://packagist.org/packages/adoy/fastcgi-client)\n\n\n## How can I use it ?\n\n```php\n\u003c?php\n\nrequire('Client.php');\nrequire('GrantType/IGrantType.php');\nrequire('GrantType/AuthorizationCode.php');\n\nconst CLIENT_ID     = 'your client id';\nconst CLIENT_SECRET = 'your client secret';\n\nconst REDIRECT_URI           = 'http://url/of/this.php';\nconst AUTHORIZATION_ENDPOINT = 'https://graph.facebook.com/oauth/authorize';\nconst TOKEN_ENDPOINT         = 'https://graph.facebook.com/oauth/access_token';\n\n$client = new OAuth2\\Client(CLIENT_ID, CLIENT_SECRET);\nif (!isset($_GET['code']))\n{\n    $auth_url = $client-\u003egetAuthenticationUrl(AUTHORIZATION_ENDPOINT, REDIRECT_URI);\n    header('Location: ' . $auth_url);\n    die('Redirect');\n}\nelse\n{\n    $params = array('code' =\u003e $_GET['code'], 'redirect_uri' =\u003e REDIRECT_URI);\n    $response = $client-\u003egetAccessToken(TOKEN_ENDPOINT, 'authorization_code', $params);\n    parse_str($response['result'], $info);\n    $client-\u003esetAccessToken($info['access_token']);\n    $response = $client-\u003efetch('https://graph.facebook.com/me');\n    var_dump($response, $response['result']);\n}\n```\n\n## How can I add a new Grant Type ?\n\nSimply write a new class in the namespace OAuth2\\GrantType. You can place the class file under GrantType.\nHere is an example :\n\n```php\n\u003c?php\n\nnamespace OAuth2\\GrantType;\n\n/**\n * MyCustomGrantType Grant Type\n */\nclass MyCustomGrantType implements IGrantType\n{\n    /**\n     * Defines the Grant Type\n     *\n     * @var string  Defaults to 'my_custom_grant_type'.\n     */\n    const GRANT_TYPE = 'my_custom_grant_type';\n\n    /**\n     * Adds a specific Handling of the parameters\n     *\n     * @return array of Specific parameters to be sent.\n     * @param  mixed  $parameters the parameters array (passed by reference)\n     */\n    public function validateParameters(\u0026$parameters)\n    {\n        if (!isset($parameters['first_mandatory_parameter']))\n        {\n            throw new \\Exception('The \\'first_mandatory_parameter\\' parameter must be defined for the Password grant type');\n        }\n        elseif (!isset($parameters['second_mandatory_parameter']))\n        {\n            throw new \\Exception('The \\'seconde_mandatory_parameter\\' parameter must be defined for the Password grant type');\n        }\n    }\n}\n```\n\ncall the OAuth client getAccessToken with the grantType you defined in the GRANT_TYPE constant, As following :\n\n```\n$response = $client-\u003egetAccessToken(TOKEN_ENDPOINT, 'my_custom_grant_type', $params);\n```\n\n## LICENSE\n\nThis Code is released under the GNU LGPL\n\nPlease do not change the header of the file(s).\n\nThis library is free software; you can redistribute it and/or modify it\nunder the terms of the GNU Lesser General Public License as published\nby the Free Software Foundation; either version 2 of the License, or\n(at your option) any later version.\n\nThis library is distributed in the hope that it will be useful, but\nWITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\nor FITNESS FOR A PARTICULAR PURPOSE.\n\nSee the GNU Lesser General Public License for more details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadoy%2Fphp-oauth2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadoy%2Fphp-oauth2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadoy%2Fphp-oauth2/lists"}