{"id":15023023,"url":"https://github.com/lrf141/oauth2-mastodon","last_synced_at":"2025-08-08T05:04:43.485Z","repository":{"id":62519487,"uuid":"146603524","full_name":"lrf141/oauth2-mastodon","owner":"lrf141","description":"Mastodon OAuth 2.0 support for the PHP League's OAuth 2.0 Client","archived":false,"fork":false,"pushed_at":"2018-08-31T08:16:41.000Z","size":35,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-09T20:32:23.496Z","etag":null,"topics":["mastodon","mastodon-api","oauth2","oauth2-client"],"latest_commit_sha":null,"homepage":null,"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/lrf141.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-29T13:24:50.000Z","updated_at":"2024-05-31T01:12:34.000Z","dependencies_parsed_at":"2022-11-02T14:00:19.506Z","dependency_job_id":null,"html_url":"https://github.com/lrf141/oauth2-mastodon","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/lrf141/oauth2-mastodon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lrf141%2Foauth2-mastodon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lrf141%2Foauth2-mastodon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lrf141%2Foauth2-mastodon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lrf141%2Foauth2-mastodon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lrf141","download_url":"https://codeload.github.com/lrf141/oauth2-mastodon/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lrf141%2Foauth2-mastodon/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265205690,"owners_count":23727511,"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":["mastodon","mastodon-api","oauth2","oauth2-client"],"created_at":"2024-09-24T19:58:38.892Z","updated_at":"2025-08-08T05:04:43.464Z","avatar_url":"https://github.com/lrf141.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# oauth2-mastodon\n\n[![Latest Stable Version](https://poser.pugx.org/lrf141/oauth2-mastodon/v/stable)](https://packagist.org/packages/lrf141/oauth2-mastodon)\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status](https://travis-ci.org/lrf141/oauth2-mastodon.svg?branch=master)](https://travis-ci.org/lrf141/oauth2-mastodon)\n[![Code Coverage](https://scrutinizer-ci.com/g/lrf141/oauth2-mastodon/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/lrf141/oauth2-mastodon/?branch=master)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/lrf141/oauth2-mastodon/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/lrf141/oauth2-mastodon/?branch=master)\n[![Total Downloads](https://img.shields.io/packagist/dt/lrf141/oauth2-mastodon.svg?style=flat-square)](https://packagist.org/packages/lrf141/oauth2-mastodon)\n\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require lrf141/oauth2-mastodon\n```\n\n## Usage\n\n``` php\n\u003c?php\n\nuse Lrf141\\OAuth2\\Client\\Provider\\Mastodon;\n\nsession_start();\n\n$provider = new Mastodon([\n    'clientId' =\u003e '',\n    'clientSecret' =\u003e '',\n    'redirectUri' =\u003e 'redirect url',\n    'instance' =\u003e 'https://mstdn.jp',\n    'scope' =\u003e 'read write follow',\n]);\n\n\nif (!isset($_GET['code'])) {\n\n    $authUrl = $provider-\u003egetAuthorizationUrl();\n\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        $user = $provider-\u003egetResourceOwner($token);\n       \n        echo $user-\u003egetName();\n        \n    } catch(Exception $e) {\n       \n       \n        exit('Oh dear...');\n    }\n\n\n    echo $token-\u003egetToken();\n}\n\n```\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email ghost141.kentyo @ gmail.com instead of using the issue tracker.\n\n## Credits\n\n- [K.Takeuchi][link-author]\n- [All Contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/:vendor/:package_name.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/:vendor/:package_name/master.svg?style=flat-square\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/:vendor/:package_name.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/:vendor/:package_name.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/:vendor/:package_name.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/:vendor/:package_name\n[link-travis]: https://travis-ci.org/:vendor/:package_name\n[link-scrutinizer]: https://scrutinizer-ci.com/g/:vendor/:package_name/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/:vendor/:package_name\n[link-downloads]: https://packagist.org/packages/:vendor/:package_name\n[link-author]: https://github.com/:author_username\n[link-contributors]: ../../contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flrf141%2Foauth2-mastodon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flrf141%2Foauth2-mastodon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flrf141%2Foauth2-mastodon/lists"}