DynamoDB: Can't Log In
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- nextjs, nodejs, typescript
- Domain
- authentication, databases
Research direction
Start with the adapter entry point at @web/lib/auth/nextAuthDynamoAdapter and the NextAuth configuration shown in the issue. Reproduce the Google sign-in using the database session strategy and inspect the adapter_getSessionAndUser flow described in the debug output. Done means database sessions complete sign-in and expose the expected user or account data, with a useful error when they do not.
Written by the indexing model from the issue text.
Description
Adapter type
@next-auth/dynamodb-adapter
Environment
System:
OS: macOS 13.2
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 853.02 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.15.0 - /usr/local/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 9.2.0 - /usr/local/bin/npm
Browsers:
Brave Browser: 110.1.48.171
Chrome: 109.0.5414.87
Firefox: 105.0.3
Safari: 16.3
npmPackages:
@next-auth/dynamodb-adapter: ^3.0.1 => 3.0.1
Reproduction URL
none
Describe the issue
I followed the instructions here exactly: https://next-auth.js.org/adapters/dynamodb
When I try to sign in with the Google provider, I am not signed in, and there is no error message. I see the account/user/sessions created in the DB:
If I switch strategy to jwt then everything works perfectly except I don't have access to the user/account inside my session. Using the default database provider simply fails to log me in.
How to reproduce
import { nextAuthDynamoAdapter } from "@web/lib/auth/nextAuthDynamoAdapter"
import NextAuth, { NextAuthOptions } from "next-auth"
import GoogleProvider from "next-auth/providers/google"
export const authOptions: NextAuthOptions = {
providers: [
GoogleProvider({
// yes these are correct
clientId: process.env.GOOGLE_CLIENT_ID || "",
clientSecret: process.env.GOOGLE_CLIENT_SECRET || "",
}),
],
adapter: nextAuthDynamoAdapter,
// session: {
// strategy: "jwt",
// maxAge: 90 * 24 * 60 * 60, // 90 days, change it as you like
// },
callbacks: {
},
}
export default NextAuth(authOptions)
Sign in with google
You are not logged in, nothing in console or logs
Set strategy to jwt and you can log in fine
Expected behavior
I would like access to the account/user objects in my session. What I would like to do is create objects in the DB attached to a user, but I don't have a way to get the userid/accountid if I'm using the jwt strategy. I'd be happy to use the database strategy but it's unclear to my why I simply can't log in when using it because the data appears correctly in the DB, the next-auth.session-token cookie is set, and I can log in okay when using the jwt strategy. And there is no useful output in the browser or server.
If I enable debug I have this output:
[next-auth][debug][OAUTH_CALLBACK_RESPONSE] {
profile: {
...
},
account: {
provider: 'google',
type: 'oauth',
...
token_type: 'Bearer',
id_token: 'xxx'
},
OAuthProfile: {
xxx
iat: 1678085335,
exp: 1678088935
}
}
[next-auth][debug][adapter_getUserByAccount] {
args: [
{ providerAccountId: 'xxx', provider: 'google' }
]
}
[next-auth][debug][adapter_getSessionAndUser] { args: [ '4dede7fc-8cba-4c40-8158-xxx' ] }
[next-auth][debug][adapter_getUserByAccount] {
args: [
{ providerAccountId: 'xxx', provider: 'google' }
]
}
But it just kicks me back to the login screen if using strategy database.
- Dominant language
- TypeScript
- Stars
- 28.4k
- Forks
- 4k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nextauthjs/next-auth
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
nextauthjs/next-auth#13495 ·
-
triage
Difficulty 1/5 Under an hour Newbie friendliness 88/100
nextauthjs/next-auth#13483 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
nextauthjs/next-auth#13475 ·
-
triage
Difficulty 1/5 Under an hour Newbie friendliness 88/100
nextauthjs/next-auth#13472 ·
-
bug triage
Difficulty 1/5 Under an hour Newbie friendliness 68/100
nextauthjs/next-auth#13204 ·
All issues in nextauthjs/next-auth
Similar issues
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 76/100
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
vercel/react-tweet#225 ·