{"id":25947255,"url":"https://github.com/n138-kz/sso_discord","last_synced_at":"2026-03-06T19:37:59.886Z","repository":{"id":273515281,"uuid":"919968243","full_name":"n138-kz/sso_discord","owner":"n138-kz","description":null,"archived":false,"fork":false,"pushed_at":"2025-11-21T17:18:40.000Z","size":232,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-21T19:18:06.986Z","etag":null,"topics":["authn","discord","discord-api","discord-bot","discord-fileupload"],"latest_commit_sha":null,"homepage":"https://n138-kz.github.io/sso_discord/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/n138-kz.png","metadata":{"files":{"readme":".github/README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-01-21T10:34:05.000Z","updated_at":"2025-11-21T15:53:26.000Z","dependencies_parsed_at":"2025-01-21T11:33:54.198Z","dependency_job_id":"84921723-116e-48b7-99a6-edff16eb634b","html_url":"https://github.com/n138-kz/sso_discord","commit_stats":null,"previous_names":["n138-kz/sso_discord"],"tags_count":0,"template":false,"template_full_name":"n138-kz/_DEFAULTREPOS","purl":"pkg:github/n138-kz/sso_discord","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n138-kz%2Fsso_discord","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n138-kz%2Fsso_discord/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n138-kz%2Fsso_discord/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n138-kz%2Fsso_discord/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/n138-kz","download_url":"https://codeload.github.com/n138-kz/sso_discord/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n138-kz%2Fsso_discord/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30193654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T19:07:06.838Z","status":"ssl_error","status_checked_at":"2026-03-06T18:57:34.882Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["authn","discord","discord-api","discord-bot","discord-fileupload"],"created_at":"2025-03-04T10:18:51.250Z","updated_at":"2026-03-06T19:37:54.871Z","avatar_url":"https://github.com/n138-kz.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [sso_discord](https://github.com/n138-kz/sso_discord)\n\n## Activity\n\n[![GitHub repo license](https://img.shields.io/github/license/n138-kz/sso_discord)](/LICENSE)\n[![GitHub repo size](https://img.shields.io/github/repo-size/n138-kz/sso_discord)](/../../)\n[![GitHub repo file count](https://img.shields.io/github/directory-file-count/n138-kz/sso_discord)](/../../)\n[![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/n138-kz/sso_discord)](/../../)\n[![GitHub last commit](https://img.shields.io/github/last-commit/n138-kz/sso_discord)](/../../commits)\n[![GitHub commit activity](https://img.shields.io/github/commit-activity/w/n138-kz/sso_discord)](/../../commits)\n[![GitHub commit activity](https://img.shields.io/github/commit-activity/t/n138-kz/sso_discord)](/../../commits)\n[![GitHub issues](https://img.shields.io/github/issues/n138-kz/sso_discord)](/../../issues)\n[![GitHub issues closed](https://img.shields.io/github/issues-closed/n138-kz/sso_discord)](/../../issues)\n[![GitHub pull requests closed](https://img.shields.io/github/issues-pr-closed/n138-kz/sso_discord)](/../../pulls)\n[![GitHub pull requests](https://img.shields.io/github/issues-pr/n138-kz/sso_discord)](/../../pulls)\n[![GitHub language count](https://img.shields.io/github/languages/count/n138-kz/sso_discord)](/../../)\n[![GitHub top language](https://img.shields.io/github/languages/top/n138-kz/sso_discord)](/../../)\n\n## Refs\n\n- [![](https://www.google.com/s2/favicons?size=64\u0026domain=https://discord.com)Discord公式リファレンス](https://discord.com/developers/docs/topics/oauth2)\n- [![](https://www.google.com/s2/favicons?size=64\u0026domain=https://discord.com)Developer Console](https://discord.com/developers/applications)\n- [![](https://www.google.com/s2/favicons?size=64\u0026domain=https://qiita.com)「DiscordのIDでログイン」を実装する(Oauth2)](https://qiita.com/masayoshi4649/items/46fdb744cb8255f5eb98)\n- [![](https://www.google.com/s2/favicons?size=64\u0026domain=https://qiita.com)PHP、CURLFileでファイルをアップロードする。(multipart/form-data、POST)](https://qiita.com/Pell/items/4ed98c906fd6a580a33f)\n- [![](https://www.google.com/s2/favicons?size=64\u0026domain=https://scrapbox.io)OAuth2 Scopesの一覧](https://scrapbox.io/discordwiki/OAuth2_Scopes%E3%81%AE%E4%B8%80%E8%A6%A7)\n- [![](https://www.google.com/s2/favicons?size=64\u0026domain=https://github.com)http_post](https://github.com/n138-kz/http_post)\n\n\u003cdetails\u003e\n\n\t\u003csummary\u003ePHP、CURLFileでファイルをアップロードする。(multipart/form-data、POST)\u003c/summary\u003e\n\n\t```php\n\t$curl_file = new \\CURLFile($_FILES['uploadfile'][\"tmp_name\"], $_FILES['uploadfile'][\"type\"], $_FILES['uploadfile'][\"name\"]);\n\t$option = [\n\t    'aaa' =\u003e 'AAA',\n\t    'bbb' =\u003e 'BBB',\n\t];\n\t$option_encode = json_encode($option);\n\t$param = [\n\t    // $curl_fileと、その他に必要なパラメータがあればここに追加。\n\t    'file' =\u003e $curl_file,\n\t    'pass' =\u003e \"abcdef\",\n\t    'option' =\u003e $option_encode,\n\t];\n\t$postdata = $param;\n\n\t$ch = curl_init();\n\tcurl_setopt($ch, CURLOPT_URL, \"https://xxx.jp/yyy/zzz.php\");\n\tcurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\n\tcurl_setopt($ch, CURLOPT_HTTPHEADER, array(\"Content-Type: multipart/form-data\"));\n\tcurl_setopt($ch, CURLOPT_POST, true);\n\tcurl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);\n\t$result = curl_exec($ch);\n\t$result_decode = json_decode($result, true);\n\t```\n\n\u003c/details\u003e\n\n## Flow\n\n1. [OAuth2](https://discord.com/oauth2/authorize?client_id=1331215597119340585\u0026response_type=code\u0026redirect_uri=https%3A%2F%2Fn138-kz.github.io%2Fsso_discord%2F\u0026scope=identify+email)を突いてもらい、Discord側の認証する\n2. `redirect_url`先のページのURLに付いている`code`を送ってもらう\n3. `code`を[Discord](https://discordapp.com/api/oauth2/token)に送り、`access_code`をもらう\n4. `access_code`を使用してユーザの情報を拾う\n\n\u003e [!TIP]\n\u003e `code`はアクセスコードを貰うためだけのトークン  \n\u003e ユーザ情報とかは`access_code`を使用する\n\n## Setup(memo)\n\n- [client](#client)\n- [server](#server)\n\n### client\n\n1. View the https://n138-kz.github.io/sso_discord\n\n### server\n\n1. Download the this repository.\n1. Fix the `CLIENT_ID`, `CLIENT_SECRET`, `REDIRECT_URL` in `./.secret/config.json` \n\n### Shell\n\n|Name|Value|\n|-|-|\n|Client ID|`1331215597119340585`|\n|Client Secret|` `|\n|Oauth URL|[OAuth2](https://discord.com/oauth2/authorize?client_id=1331215597119340585\u0026response_type=code\u0026redirect_uri=https%3A%2F%2Fn138-kz.github.io%2Fsso_discord%2F\u0026scope=identify+email)|\n\n```sh\nclient_id='1331215597119340585' # Follow the developer console, into bot info\nclient_secret='' # Follow the developer console, into bot info\nredirect_uri='https://n138-kz.github.io/sso_discord/' # Follow the developer console, into bot info\naccess_code='' # Generate by discord api server after Click OAuth link then auth\n\naccess_token_raw=$(curl -X POST -H \"Content-Type:application/x-www-form-urlencoded\" -d \"client_id=${client_id}\u0026client_secret=${client_secret}\u0026grant_type=authorization_code\u0026code=${access_code}\u0026redirect_uri=${redirect_uri}\" https://discordapp.com/api/oauth2/token)\necho ${access_token_raw} | jq\naccess_token=$(echo ${access_token_raw} | jq -r .access_token)\ncurl -H \"Authorization: Bearer ${access_token}\" https://discordapp.com/api/users/@me\n```\n\n#### sample output\n\n```json\n{\n  \"id\": \"0000000000000000\",\n  \"username\": \"Your_name\",\n  \"avatar\": \"00000000000000000000000000000000\",\n  \"discriminator\": \"0\",\n  \"public_flags\": 0,\n  \"flags\": 0,\n  \"banner\": null,\n  \"accent_color\": null,\n  \"global_name\": null,\n  \"avatar_decoration_data\": null,\n  \"banner_color\": \"#000000\",\n  \"clan\": null,\n  \"primary_guild\": null,\n  \"mfa_enabled\": true,\n  \"locale\": \"ja\",\n  \"premium_type\": 0,\n  \"email\": \"your@example.org\",\n  \"verified\": true\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn138-kz%2Fsso_discord","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fn138-kz%2Fsso_discord","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn138-kz%2Fsso_discord/lists"}