You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Let the Next.js example sign in without an OAuth app, using a GitHub mock in development
#13518
A fresh clone of apps/examples/nextjs can sign in locally without registering an OAuth app.
The example gets a Playwright sign-in test that can run in CI.
Production and next-auth-example.vercel.app don't change.
Non-Goals
No changes to any next-auth or @auth/* package.
No changes to the other examples for now. SvelteKit could follow if this works out.
Background
To try sign-in in the Next.js example today, you first register an OAuth app with some provider and copy its client ID and secret. A fresh clone also fails every Auth.js request until seven providers get issuer URLs; #13516 fixes that on its own.
Real providers also get in the way of automated tests: bot checks, 2FA and rate limits. The repo's own E2E job signs in through a Keycloak instance set up with repo secrets, and the example has no test at all. People keep asking how to test sign-in end to end: #8718, #11299, #12183, #2053, #11046, #9773.
Proposal
Would you accept letting the example's GitHub button sign in through a hosted GitHub mock outside production? You could then try sign-in right after cloning, and the example gets a sign-in test. The code is ready to read in #13517. If not, no hard feelings: I'll close it.
What changes
One line in auth.ts. Production is unchanged: it still uses GitHub with AUTH_GITHUB_ID/AUTH_GITHUB_SECRET. The provider id stays github, so the UI doesn't change.
tests/signin.spec.ts and playwright.config.ts, laid out like packages/next-auth's config. One test checks that GitHub sign-in reaches the mock's login page and needs no credentials. The full sign-in/sign-out test skips unless MOCKATOO_TEST_EMAIL and MOCKATOO_TEST_PASSWORD are set.
.github/workflows/example-nextjs.yml, which builds the example and runs the test on changes to apps/examples/nextjs/**. On PRs from forks it runs the build and the credential-free test only.
A README section, .env.local.example entries, and @mockatoo/connect-authjs (a thin wrapper around next-auth/providers/github).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Goals
apps/examples/nextjscan sign in locally without registering an OAuth app.Non-Goals
next-author@auth/*package.Background
To try sign-in in the Next.js example today, you first register an OAuth app with some provider and copy its client ID and secret. A fresh clone also fails every Auth.js request until seven providers get issuer URLs; #13516 fixes that on its own.
Real providers also get in the way of automated tests: bot checks, 2FA and rate limits. The repo's own E2E job signs in through a Keycloak instance set up with repo secrets, and the example has no test at all. People keep asking how to test sign-in end to end: #8718, #11299, #12183, #2053, #11046, #9773.
Proposal
Would you accept letting the example's GitHub button sign in through a hosted GitHub mock outside production? You could then try sign-in right after cloning, and the example gets a sign-in test. The code is ready to read in #13517. If not, no hard feelings: I'll close it.
What changes
auth.ts. Production is unchanged: it still uses GitHub withAUTH_GITHUB_ID/AUTH_GITHUB_SECRET. The provider id staysgithub, so the UI doesn't change.tests/signin.spec.tsandplaywright.config.ts, laid out likepackages/next-auth's config. One test checks that GitHub sign-in reaches the mock's login page and needs no credentials. The full sign-in/sign-out test skips unlessMOCKATOO_TEST_EMAILandMOCKATOO_TEST_PASSWORDare set..github/workflows/example-nextjs.yml, which builds the example and runs the test on changes toapps/examples/nextjs/**. On PRs from forks it runs the build and the credential-free test only..env.local.exampleentries, and@mockatoo/connect-authjs(a thin wrapper aroundnext-auth/providers/github).The workflow passed on our fork, including the full sign-in: https://github.com/mockatoo/next-auth/actions/runs/43650315528. No credentials are in the code.
Disclosure: I build Mockatoo, the free hosted mock used here. The connectors are open source at https://github.com/mockatoo/connectors.
Happy to change the approach: only the test and no default change, a separate example, or nothing at all.
All reactions