{"id":46782823,"url":"https://github.com/omermecitoglu/oauth-kit","last_synced_at":"2026-03-10T00:36:07.906Z","repository":{"id":336815540,"uuid":"1151116640","full_name":"omermecitoglu/oauth-kit","owner":"omermecitoglu","description":"Server-side OAuth utilities for implementing multiple OAuth providers.","archived":false,"fork":false,"pushed_at":"2026-02-06T09:03:12.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-06T16:30:47.338Z","etag":null,"topics":["apple-oauth2-jwt","google-oauth2","oauth2"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/omermecitoglu.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,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-06T04:24:21.000Z","updated_at":"2026-02-06T09:02:40.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/omermecitoglu/oauth-kit","commit_stats":null,"previous_names":["omermecitoglu/oauth-kit"],"tags_count":1,"template":false,"template_full_name":"omermecitoglu/node-module","purl":"pkg:github/omermecitoglu/oauth-kit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omermecitoglu%2Foauth-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omermecitoglu%2Foauth-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omermecitoglu%2Foauth-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omermecitoglu%2Foauth-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omermecitoglu","download_url":"https://codeload.github.com/omermecitoglu/oauth-kit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omermecitoglu%2Foauth-kit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30318581,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T20:05:46.299Z","status":"ssl_error","status_checked_at":"2026-03-09T19:57:04.425Z","response_time":61,"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":["apple-oauth2-jwt","google-oauth2","oauth2"],"created_at":"2026-03-10T00:36:07.309Z","updated_at":"2026-03-10T00:36:07.893Z","avatar_url":"https://github.com/omermecitoglu.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# oauth-kit\n\n[![npm version](https://img.shields.io/npm/v/@omer-x/oauth-kit?logo=npm\u0026logoColor=CB3837\u0026color=CB3837)](https://www.npmjs.com/package/@omer-x/oauth-kit)\n[![npm downloads](https://img.shields.io/npm/dm/@omer-x/oauth-kit?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNi4wIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjQgRm9udGljb25zLCBJbmMuLS0+PHBhdGggZD0iTTI4OCAzMmMwLTE3LjctMTQuMy0zMi0zMi0zMnMtMzIgMTQuMy0zMiAzMmwwIDI0Mi43LTczLjQtNzMuNGMtMTIuNS0xMi41LTMyLjgtMTIuNS00NS4zIDBzLTEyLjUgMzIuOCAwIDQ1LjNsMTI4IDEyOGMxMi41IDEyLjUgMzIuOCAxMi41IDQ1LjMgMGwxMjgtMTI4YzEyLjUtMTIuNSAxMi41LTMyLjggMC00NS4zcy0zMi44LTEyLjUtNDUuMyAwTDI4OCAyNzQuNyAyODggMzJ6TTY0IDM1MmMtMzUuMyAwLTY0IDI4LjctNjQgNjRsMCAzMmMwIDM1LjMgMjguNyA2NCA2NCA2NGwzODQgMGMzNS4zIDAgNjQtMjguNyA2NC02NGwwLTMyYzAtMzUuMy0yOC43LTY0LTY0LTY0bC0xMDEuNSAwLTQ1LjMgNDUuM2MtMjUgMjUtNjUuNSAyNS05MC41IDBMMTY1LjUgMzUyIDY0IDM1MnptMzY4IDU2YTI0IDI0IDAgMSAxIDAgNDggMjQgMjQgMCAxIDEgMC00OHoiIGZpbGw9IiMwMDc4MjAiIC8+PC9zdmc+\u0026color=007820)](https://www.npmjs.com/package/@omer-x/oauth-kit)\n[![codecov](https://codecov.io/gh/omermecitoglu/oauth-kit/branch/main/graph/badge.svg)](https://codecov.io/gh/omermecitoglu/oauth-kit)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NDAgNTEyIj48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNi4wIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXN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xIDYuNyAzMi4xQzI0MiAzODIgMTg5LjcgNDE2IDEyNi44IDQxNlMxMS43IDM4MiAuOSAzMzcuMXoiIGZpbGw9IiNEMEE4MUMiIC8+PC9zdmc+)](https://opensource.org/licenses/MIT)\n[![GitHub last commit](https://img.shields.io/github/last-commit/omermecitoglu/oauth-kit?color=c977be\u0026logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NDAgNTEyIj48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNi4wIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjQgRm9udGljb25zLCBJbmMuLS0+PHBhdGggZD0iTTMyMCAzMzZhODAgODAgMCAxIDAgMC0xNjAgODAgODAgMCAxIDAgMCAxNjB6bTE1Ni44LTQ4QzQ2MiAzNjEgMzk3LjQgNDE2IDMyMCA0MTZzLTE0Mi01NS0xNTYuOC0xMjhMMzIgMjg4Yy0xNy43IDAtMzItMTQuMy0zMi0zMnMxNC4zLTMyIDMyLTMybDEzMS4yIDBDMTc4IDE1MSAyNDIuNiA5NiAzMjAgOTZzMTQyIDU1IDE1Ni44IDEyOEw2MDggMjI0YzE3LjcgMCAzMiAxNC4zIDMyIDMycy0xNC4zIDMyLTMyIDMybC0xMzEuMiAweiIgZmlsbD0iI0M5NzdCRSIgLz48L3N2Zz4=)](https://github.com/omermecitoglu/oauth-kit/commits/main/)\n[![GitHub issues](https://img.shields.io/github/issues/omermecitoglu/oauth-kit?color=a38eed\u0026logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNiAxNiIgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2Ij4KICA8cGF0aCBkPSJNOCA5LjVhMS41IDEuNSAwIDEgMCAwLTMgMS41IDEuNSAwIDAgMCAwIDNaIiBmaWxsPSIjQTM4RUVEIj48L3BhdGg+CiAgPHBhdGggZD0iTTggMGE4IDggMCAxIDEgMCAxNkE4IDggMCAwIDEgOCAwWk0xLjUgOGE2LjUgNi41IDAgMSAwIDEzIDAgNi41IDYuNSAwIDAgMC0xMyAwWiIgZmlsbD0iI0EzOEVFRCI+PC9wYXRoPgo8L3N2Zz4=)](https://github.com/omermecitoglu/oauth-kit/issues)\n[![GitHub stars](https://img.shields.io/github/stars/omermecitoglu/oauth-kit?style=social)](https://github.com/omermecitoglu/oauth-kit)\n\n## Table of Contents\n\n- [Overview](#overview)\n- [Installation](#installation)\n- [How to use](#how-to-use)\n  - [Provide a url to redirect users to the OAuth provider's authentication page](#provide-a-url-to-redirect-users-to-the-oauth-providers-authentication-page)\n  - [How to use get user information (Apple) with a Next.js API route](#how-to-use-get-user-information-apple-with-a-nextjs-api-route)\n  - [How to use get user information (Google) with a Next.js API route](#how-to-use-get-user-information-google-with-a-nextjs-api-route)\n- [License](#license)\n\n## Overview\n\nServer-side OAuth utilities for implementing multiple OAuth providers.\n\n## Installation\n\nTo install this package\n\n```sh\nnpm install @omer-x/oauth-kit\n```\n\n## How to use\n\n### Provide a url to redirect users to the OAuth provider's authentication page\n\n```typescript\nimport { generateOAuthURL as loginWithAppleURL } from \"@omer-x/oauth-kit/apple/client\";\nimport { generateOAuthURL as loginWithGoogleURL } from \"@omer-x/oauth-kit/google/client\";\n\n// process.env.GOOGLE_OAUTH_CLIENT_ID = your Google OAuth Client ID from Google Cloud Console\n// publicOrigin = public origin of your app e.g. \"https://myapp.com\"\n// callbackEndpoint = endpoint to handle the OAuth callback e.g. \"/auth/google\"\n// locale = locale code e.g. \"en\", \"fr\", \"de\"\n\nloginWithGoogleURL(process.env.GOOGLE_OAUTH_CLIENT_ID, publicOrigin, \"/auth/google\", locale);\nloginWithAppleURL(process.env.APPLE_OAUTH_CLIENT_ID, publicOrigin, \"/auth/apple\", locale);\n```\n\n### How to use get user information (Apple) with a Next.js API route\n\n```typescript\nimport { createAccessToken } from \"@omer-x/oauth-kit/apple/access-token\";\nimport { decodeIdToken, signClientSecret } from \"@omer-x/oauth-kit/apple/jwt\";\nimport { parseOneTimeUserInfo } from \"@omer-x/oauth-kit/apple/utils\";\nimport { decodeState } from \"@omer-x/oauth-kit/utils\";\nimport { hasLocale } from \"next-intl\";\nimport { routing } from \"~/i18n/routing\";\n\nexport async function POST(request: Request) {\n  const [\n    formData,\n    publicOrigin, // public origin of your app e.g. \"https://myapp.com\"\n  ] = await Promise.all([\n    request.formData(),\n    getPublicOrigin(request.headers), // implement this function to get the public origin from request headers\n  ]);\n  const { pathname } = new URL(request.url);\n  const originURL = new URL(pathname, publicOrigin).toString();\n\n  const state = formData.get(\"state\");\n  const code = formData.get(\"code\");\n  const rawUserData = formData.get(\"user\");\n\n  if (typeof code !== \"string\") throw new Error(\"Invalid code\");\n  if (typeof state !== \"string\") throw new Error(\"Invalid state\");\n\n  if (!process.env.APPLE_OAUTH_TEAM_ID) throw new Error(\"APPLE_OAUTH_TEAM_ID env is missing!\");\n  if (!process.env.APPLE_OAUTH_CLIENT_ID) throw new Error(\"APPLE_OAUTH_CLIENT_ID env is missing!\");\n  if (!process.env.APPLE_OAUTH_KEY_ID) throw new Error(\"APPLE_OAUTH_KEY_ID env is missing!\");\n  if (!process.env.APPLE_OAUTH_PRIVATE_KEY) throw new Error(\"APPLE_OAUTH_PRIVATE_KEY env is missing!\");\n\n  const { locale } = decodeState(state);\n  if (!hasLocale(routing.locales, locale)) throw new Error(`Unknown Locale (${locale})`);\n\n  const clientSecret = signClientSecret(\n    process.env.APPLE_OAUTH_TEAM_ID,\n    process.env.APPLE_OAUTH_CLIENT_ID,\n    process.env.APPLE_OAUTH_KEY_ID,\n    process.env.APPLE_OAUTH_PRIVATE_KEY,\n  );\n  const oauth = await createAccessToken(process.env.APPLE_OAUTH_CLIENT_ID, clientSecret, code, originURL);\n  const appleUser = decodeIdToken(oauth.id_token);\n  const appleUserInfo = parseOneTimeUserInfo(rawUserData); // Beware! they send this information only once, so use it wisely!\n\n  // apply your authentincation logic here, e.g. create or update user in your database\n  // then redirect the user to the app\n}\n```\n\n### How to use get user information (Google) with a Next.js API route\n\n```typescript\nimport { createAccessToken } from \"@omer-x/oauth-kit/google/access-token\";\nimport { getGoogleUser } from \"@omer-x/oauth-kit/google/api\";\nimport { fetchUserPicture } from \"@omer-x/oauth-kit/google/utils\";\nimport { decodeState } from \"@omer-x/oauth-kit/utils\";\nimport { hasLocale } from \"next-intl\";\nimport { routing } from \"~/i18n/routing\";\n\nexport async function GET(request: Request) {\n  const [\n    publicOrigin, // public origin of your app e.g. \"https://myapp.com\"\n  ] = await Promise.all([\n    getPublicOrigin(request.headers), // implement this function to get the public origin from request headers\n  ]);\n  const { searchParams, pathname } = new URL(request.url);\n  const originURL = new URL(pathname, publicOrigin).toString();\n\n  const code = searchParams.get(\"code\");\n  const state = searchParams.get(\"state\");\n\n  if (typeof code !== \"string\") throw new Error(\"Invalid code\");\n  if (typeof state !== \"string\") throw new Error(\"Invalid state\");\n\n  if (!process.env.GOOGLE_OAUTH_CLIENT_ID) throw new Error(\"GOOGLE_OAUTH_CLIENT_ID env is missing!\");\n  if (!process.env.GOOGLE_OAUTH_CLIENT_SECRET) throw new Error(\"GOOGLE_OAUTH_CLIENT_SECRET env is missing!\");\n\n  const { locale } = decodeState(state);\n  if (!hasLocale(routing.locales, locale)) throw new Error(`Unknown Locale (${locale})`);\n\n  const oauth = await createAccessToken(\n    process.env.GOOGLE_OAUTH_CLIENT_ID,\n    process.env.GOOGLE_OAUTH_CLIENT_SECRET,\n    code,\n    originURL,\n  );\n  const googleUser = await getGoogleUser(oauth.access_token);\n\n  // apply your authentincation logic here, e.g. create or update user in your database\n\n  // optional step: fetch user picture\n  const picture = await fetchUserPicture(googleUser.picture); // this is a File object, you can upload it to your storage service if you wish\n  \n  // then redirect the user to the app\n}\n```\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomermecitoglu%2Foauth-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomermecitoglu%2Foauth-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomermecitoglu%2Foauth-kit/lists"}