{"id":17683189,"url":"https://github.com/nemanjam/next-auth-custom-provider-demo","last_synced_at":"2025-09-04T04:20:42.757Z","repository":{"id":153038041,"uuid":"627797065","full_name":"nemanjam/next-auth-custom-provider-demo","owner":"nemanjam","description":"Custom Next-auth OAuth provider for Square with Prisma and Postgres.","archived":false,"fork":false,"pushed_at":"2023-06-15T20:57:01.000Z","size":1272,"stargazers_count":15,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T12:12:03.079Z","etag":null,"topics":["next-auth","next-auth-provider","nextjs","oauth2","postgresql","prisma"],"latest_commit_sha":null,"homepage":"https://next-auth-custom-provider-demo.vercel.app","language":"TypeScript","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/nemanjam.png","metadata":{"files":{"readme":"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}},"created_at":"2023-04-14T08:13:04.000Z","updated_at":"2024-08-26T12:38:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"c5f474b0-a456-4a71-911e-225453b21fbe","html_url":"https://github.com/nemanjam/next-auth-custom-provider-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemanjam%2Fnext-auth-custom-provider-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemanjam%2Fnext-auth-custom-provider-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemanjam%2Fnext-auth-custom-provider-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemanjam%2Fnext-auth-custom-provider-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nemanjam","download_url":"https://codeload.github.com/nemanjam/next-auth-custom-provider-demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249779548,"owners_count":21324415,"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":["next-auth","next-auth-provider","nextjs","oauth2","postgresql","prisma"],"created_at":"2024-10-24T09:44:37.452Z","updated_at":"2025-04-19T19:30:17.820Z","avatar_url":"https://github.com/nemanjam.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Next-auth custom provider demo\n\nDemo app for Next-auth custom provider using https://squareup.com OAuth provider. Provider implementation is in `lib/providers/square.ts`. Login is fully functional and uses sandbox test account, you must login with provided test account into Square dashboard and open `Default Test Account` in another tab and then you can test the login with Square in the demo.\n\nDemo allows login with Square, creating, publishing and deleting posts, and reseeding database for another test. It is hosted on Vercel and uses external Postgres database on separate server. It must use low latency database or login will time out and throw error.\n\n**Demo link: https://next-auth-custom-provider-demo.vercel.app**\n\nThere are also custom provider implementations for Uber and Yelp in `lib/providers/` but they are untested and incomplete, Uber doesn't allow `profile` scope for unverified apps (even though docs states opposite) and Yelp doesn't support Serbia for business accounts.\n\n## Successful login with Square screenshot\n\n![Square login](./screenshots/screenshot-demo.png)\n\n## How to test the demo\n\n1. Go to https://developer.squareup.com/apps and sign in with provided email and password for test account\n2. Click `Open` button right from `Default Test Account`, it will lead to https://squareupsandbox.com/dashboard/ and keep that tab open while testing\n3. You can now sign in with that account in the demo https://next-auth-custom-provider-demo.vercel.app\n\n![Open test account](./screenshots/open-test-account.png)\n\n## Useful Square OAuth references\n\nOfficial Next.js Prisma example that is used as a starting template:\n\n- https://github.com/prisma/prisma-examples/tree/latest/typescript/rest-nextjs-api-routes-auth\n\nMain OAuth example code:\n\n- https://github.dev/square/connect-api-examples/tree/master/connect-examples/oauth/node\n\nGet merchant profile:\n\n- https://developer.squareup.com/reference/square/merchants-api/retrieve-merchant\n\nNext-auth example for `token` and `userinfo` callbacks:\n\n- https://stackoverflow.com/questions/73345086/next-auth-custom-provider-oidc-nonce-check\n\nNext-auth OAuth docs:\n\n- https://next-auth.js.org/configuration/providers/oauth#userinfo-option\n\nNext-auth provider examples:\n\n- https://github.com/nextauthjs/next-auth/tree/main/packages/next-auth/src/providers\n\n## Running locally\n\nSupply the following environment variables in `.env.development.local`:\n\n```bash\nSECRET=RANDOM_STRING\n\n# local docker db\nPOSTGRES_HOSTNAME=localhost\nPOSTGRES_PORT=5432\nPOSTGRES_USER=postgres_user\nPOSTGRES_PASSWORD=password\nPOSTGRES_DB=cp-db-dev\n\n# db url for the app\nDATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOSTNAME}:${POSTGRES_PORT}/${POSTGRES_DB}?schema=public\n\n# Square\nSQUARE_APPLICATION_ID=\nSQUARE_APPLICATION_SECRET=\nSQUARE_ENVIRONMENT=sandbox\n```\n\nThen run:\n\n```bash\n# install dependencies\nyarn install\n\n# start Postgres database in Docker\ndocker compose up -d\n\n# migrate database (must pass env vars)\nyarn prisma:migrate:dev:env\n\n# seed database (must pass env vars)\nyarn prisma:seed:dev:env\n\n# run the app in dev mode\nyarn dev\n```\n\n## Uber references\n\n`https://api.uber.com/v1.2/me` api is not possible to call without `profile` scope which is unavailable for unverified apps\n\n- https://developer.uber.com/docs/riders/references/api/v1.2/me-get\n- https://github.com/shernshiou/node-uber#me\n\nNot true in my experience:\n\n\u003e The good news is you currently have access to these scopes when authorizing your own account or those of the developer accounts you list in your application dashboard (Limited Access). This allows you to start building an app immediately.\n\n- https://developer.uber.com/docs/riders/guides/scopes\n\n## Yelp references\n\nMust use business account for test and for register Serbia isn't an option in dropdown.\n\nUseful docs links:\n\n- https://docs.developer.yelp.com/docs/authorization-code-workflow\n\nGet user endpoint:\n\n- https://docs.developer.yelp.com/reference/oauth2_token\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnemanjam%2Fnext-auth-custom-provider-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnemanjam%2Fnext-auth-custom-provider-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnemanjam%2Fnext-auth-custom-provider-demo/lists"}