{"id":18463726,"url":"https://github.com/commandstring/discordoauth","last_synced_at":"2025-04-28T13:33:21.170Z","repository":{"id":65147895,"uuid":"583976176","full_name":"CommandString/discordoauth","owner":"CommandString","description":"A basic way to use discordoauth in php","archived":false,"fork":false,"pushed_at":"2023-01-26T07:46:41.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-16T16:57:58.184Z","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/CommandString.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-12-31T18:14:36.000Z","updated_at":"2022-12-31T18:15:10.000Z","dependencies_parsed_at":"2023-02-14T15:00:49.544Z","dependency_job_id":null,"html_url":"https://github.com/CommandString/discordoauth","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/CommandString%2Fdiscordoauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CommandString%2Fdiscordoauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CommandString%2Fdiscordoauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CommandString%2Fdiscordoauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CommandString","download_url":"https://codeload.github.com/CommandString/discordoauth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251320001,"owners_count":21570488,"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-11-06T09:07:47.921Z","updated_at":"2025-04-28T13:33:21.090Z","avatar_url":"https://github.com/CommandString.png","language":"PHP","readme":"# commandstring/discordoauth #\n\nAn easier way to get discord OAuth tokens\n\n# Requirements #\n* PHP 8.1=\u003c\n* Composer 2\n* Registered Discord application\n\n# Getting Token\nYou will need to retrieve your discord application's `client_id` and `client_secret`. After retrieving those you can instantiate the `\\CommandString\\DiscordOAuth\\OAuth` class.\n\n```php\n$OAuth = (new OAuth(\"http://localhost:8000\", $client_id, $client_secret));\n```\n\nYou will then need to define scopes by using the `addScopes` method. You can either supply a scope string or supply a Scopes enum.\n\n```php\n$OAuth-\u003eaddScopes(Scopes::IDENTIFY);\n```\n\nAfterwards you can then generate a url for the authorize endpoint by invoking the `buildAuthorizeUrl` method.\n\n```php\n$authUrl - $OAuth-\u003ebuildAuthorizeUrl();\n```\n\nAfter the client is redirected you can then use the `getToken` method for retrieving the access token.\n\n```php\n$tokenRes = $OAuth-\u003egetToken($_GET[\"code\"]);\n```\n\n*You can supply your own `\\React\\Http\\Browser` in the second argument of this method*\n\n`$tokenRes` will be an stdClass with the following structure.\n\n```json\n{\n    \"access_token\": \"\u003cstring\u003e\",\n    \"expires_in\": \"\u003cint\u003e\",\n    \"refresh_token\": \"\u003cstring\u003e\",\n    \"scope\": \"\u003cstring\u003e\",\n    \"token_type\": \"\u003cstring\u003e\"\n}\n```\n\nYou can also refresh your token with the refreshToken method...\n\n```php\n$newTokenRes = $OAuth-\u003erefreshToken($tokenRes-\u003erefresh_token);\n```\n\n# Getting user\n\n```php\n$user = User::getWithToken($tokenRes-\u003etoken_type, $tokenRes-\u003eaccess_token);\n```\n\n*Note: All properties of the user are readonly.*","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommandstring%2Fdiscordoauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcommandstring%2Fdiscordoauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommandstring%2Fdiscordoauth/lists"}