{"id":15136088,"url":"https://github.com/willin/svelte-auth-afdian","last_synced_at":"2025-09-29T05:30:27.164Z","repository":{"id":211218841,"uuid":"728537181","full_name":"willin/svelte-auth-afdian","owner":"willin","description":"See:  https://github.com/willin/svelte-turbo","archived":true,"fork":false,"pushed_at":"2023-12-08T19:20:36.000Z","size":58,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-29T18:49:32.425Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/willin.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},"funding":{"github":"willin","custom":"https://afdian.net/@willin"}},"created_at":"2023-12-07T06:38:22.000Z","updated_at":"2023-12-09T11:32:51.000Z","dependencies_parsed_at":"2023-12-07T06:40:17.786Z","dependency_job_id":"b05e127a-3b49-4d31-ae19-ebd432396cda","html_url":"https://github.com/willin/svelte-auth-afdian","commit_stats":null,"previous_names":["willin/svelte-auth-afdian"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willin%2Fsvelte-auth-afdian","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willin%2Fsvelte-auth-afdian/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willin%2Fsvelte-auth-afdian/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willin%2Fsvelte-auth-afdian/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willin","download_url":"https://codeload.github.com/willin/svelte-auth-afdian/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234594021,"owners_count":18857416,"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-09-26T06:04:03.141Z","updated_at":"2025-09-29T05:30:21.712Z","avatar_url":"https://github.com/willin.png","language":"TypeScript","funding_links":["https://github.com/sponsors/willin","https://afdian.net/@willin","https://paypal.me/willinwang"],"categories":[],"sub_categories":[],"readme":"![Logo](https://repository-images.githubusercontent.com/726691357/f09bf6fc-3844-4584-8eee-6bfb425d8a38)\n\n# svelte-auth-afdian strategy\n\nThe Afdian（爱发电） strategy is used to authenticate users against a afidan account. It extends the OAuth2Strategy.\n\nFor more details: \u003chttps://github.com/willin/svelte-auth\u003e\n\n## Supported runtimes\n\n| Runtime    | Has Support |\n| ---------- | ----------- |\n| Node.js    | ✅          |\n| Cloudflare | ✅          |\n| Vercel     | ✅          |\n\n## Usage\n\n### Create an OAuth application\n\nFollow the steps on [the Afdian(爱发电) documentation](https://afdian.net/p/010ff078177211eca44f52540025c377) to create a new application and get a client ID and secret.\n\n### Create the strategy instance\n\n```ts\nimport { AfdianStrategy } from '@svelte-dev/auth-afdian';\n\nlet strategy = new AfdianStrategy(\n  {\n    clientID: 'YOUR_CLIENT_ID',\n    clientSecret: 'YOUR_CLIENT_SECRET',\n    callbackURL: 'https://example.com/auth/afdian/callback'\n  },\n  async ({ accessToken, extraParams, profile }) =\u003e {\n    // Get the user data from your DB or API using the tokens and profile\n    return User.findOrCreate({ email: profile.emails[0].value });\n  }\n);\n\nauth.use(strategy);\n```\n\n### Setup your routes\n\n```html\n\u003cform action=\"/auth/afdian\" method=\"get\"\u003e\n  \u003cbutton\u003eLogin with Afdian（爱发电）\u003c/button\u003e\n\u003c/form\u003e\n```\n\n```tsx\n// routes/auth/afdian/+server\nimport { authenticator } from '~/auth.server';\nimport type { RequestHandler } from './$types';\n\nexport const POST: RequestHandler = async (event) =\u003e {\n  return authenticator.authenticate('afdian', event);\n};\n```\n\n```tsx\n// routes/auth/afdian/callback/+server\nimport { authenticator } from '~/auth.server';\nimport type { PageServerLoad } from './$types';\n\nexport const load: PageServerLoad = async ({ event }) =\u003e {\n  return authenticator.authenticate('afdian', event, {\n    successRedirect: '/dashboard',\n    failureRedirect: '/login'\n  });\n};\n```\n\n## 赞助 Sponsor\n\n维护者 Owner： [Willin Wang](https://willin.wang)\n\n如果您对本项目感兴趣，可以通过以下方式支持我：\n\n- 关注我的 Github 账号：[@willin](https://github.com/willin) [![github](https://img.shields.io/github/followers/willin.svg?style=social\u0026label=Followers)](https://github.com/willin)\n- 参与 [爱发电](https://afdian.net/@willin) 计划\n- 支付宝或微信[扫码打赏](https://user-images.githubusercontent.com/1890238/89126156-0f3eeb80-d516-11ea-9046-5a3a5d59b86b.png)\n\nDonation ways:\n\n- Github: \u003chttps://github.com/sponsors/willin\u003e\n- Paypal: \u003chttps://paypal.me/willinwang\u003e\n- Alipay or Wechat Pay: [QRCode](https://user-images.githubusercontent.com/1890238/89126156-0f3eeb80-d516-11ea-9046-5a3a5d59b86b.png)\n\n## 许可证 License\n\nApache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillin%2Fsvelte-auth-afdian","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillin%2Fsvelte-auth-afdian","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillin%2Fsvelte-auth-afdian/lists"}