{"id":21491889,"url":"https://github.com/chrishemmings/oauth2-digitalocean","last_synced_at":"2025-07-15T17:32:49.249Z","repository":{"id":56952378,"uuid":"51619121","full_name":"chrishemmings/oauth2-digitalocean","owner":"chrishemmings","description":"DigitalOcean OAuth 2.0 support for the PHP League's OAuth 2.0 Client","archived":false,"fork":false,"pushed_at":"2020-04-18T14:50:29.000Z","size":25,"stargazers_count":7,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-31T04:21:10.336Z","etag":null,"topics":["digitalocean","oauth2","php-league"],"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/chrishemmings.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-02-12T21:56:07.000Z","updated_at":"2024-01-17T08:30:03.000Z","dependencies_parsed_at":"2022-08-21T09:20:21.168Z","dependency_job_id":null,"html_url":"https://github.com/chrishemmings/oauth2-digitalocean","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrishemmings%2Foauth2-digitalocean","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrishemmings%2Foauth2-digitalocean/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrishemmings%2Foauth2-digitalocean/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrishemmings%2Foauth2-digitalocean/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrishemmings","download_url":"https://codeload.github.com/chrishemmings/oauth2-digitalocean/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226058306,"owners_count":17567052,"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":["digitalocean","oauth2","php-league"],"created_at":"2024-11-23T15:20:00.865Z","updated_at":"2024-11-23T15:20:01.547Z","avatar_url":"https://github.com/chrishemmings.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DigitalOcean Provider for OAuth 2.0 Client\n[![Latest Version](https://img.shields.io/github/release/chrishemmings/oauth2-digitalocean.svg?style=flat-square)](https://github.com/chrishemmings/oauth2-digitalocean/releases)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n[![Build Status](https://img.shields.io/travis/chrishemmings/oauth2-digitalocean/master.svg?style=flat-square)](https://travis-ci.org/chrishemmings/oauth2-digitalocean)\n[![Quality Score](https://img.shields.io/scrutinizer/g/chrishemmings/oauth2-digitalocean.svg?style=flat-square)](https://scrutinizer-ci.com/g/chrishemmings/oauth2-digitalocean)\n[![Total Downloads](https://img.shields.io/packagist/dt/chrishemmings/oauth2-digitalocean.svg?style=flat-square)](https://packagist.org/packages/chrishemmings/oauth2-digitalocean)\n\n\nThis package provides DigitalOcean 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 chrishemmings/oauth2-digitalocean\n```\n\n## Usage\n\nUsage is the same as The League's OAuth client, using `\\ChrisHemmings\\OAuth2\\Client\\Provider\\DigitalOcean` as the provider.\n\n### Authorization Code Flow\n\n```php\n\nrequire_once('./vendor/autoload.php');\nsession_start();\n\n$provider = new \\ChrisHemmings\\OAuth2\\Client\\Provider\\DigitalOcean([\n    'clientId'          =\u003e '{digitalocean-client-id}',\n    'clientSecret'      =\u003e '{digitalocean-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\n## Testing\n\n``` bash\n$ ./vendor/bin/phpunit\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/chrishemmings/oauth2-digitalocean/blob/master/CONTRIBUTING.md) for details.\n\n## Credits\n\n- [Chris Hemmings](https://github.com/chrishemmings)\n- [Daniel Hensby](https://github.com/dhensby)\n- [All Contributors](https://github.com/chrishemmings/oauth2-digitalocean/contributors)\n\n\n## License\n\nThe MIT License (MIT). Please see [License File](https://github.com/chrishemmings/oauth2-digitalocean/blob/master/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrishemmings%2Foauth2-digitalocean","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrishemmings%2Foauth2-digitalocean","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrishemmings%2Foauth2-digitalocean/lists"}