NextJS auth question
Unanswered
Mugger Crocodile posted this in #help-forum
Mugger CrocodileOP
Hiya,
I've recently been adding auth to my app, and now on the stage of adding oath. Because I was looking for a bit of a challenge, I decided to implement it myself with no AI, just raw oauth documentation and my own interpretation. So far its going really well however I've gotten to the point where I need to save the oauth data in my db. BUT, upon looking at the next-auth schema recommendation, I have no idea what some of the fields are meant to hold (i will mark with an *). if anyone can assist in explaining them to me, I would be more than grateful. Thanks.
I've recently been adding auth to my app, and now on the stage of adding oath. Because I was looking for a bit of a challenge, I decided to implement it myself with no AI, just raw oauth documentation and my own interpretation. So far its going really well however I've gotten to the point where I need to save the oauth data in my db. BUT, upon looking at the next-auth schema recommendation, I have no idea what some of the fields are meant to hold (i will mark with an *). if anyone can assist in explaining them to me, I would be more than grateful. Thanks.
model Account {
id String @id @default(cuid())
userId String @map("user_id")
* type String
* provider String
* providerAccountId String @map("provider_account_id")
refresh_token String? @db.Text
access_token String? @db.Text
expires_at Int?
* token_type String?
scope String?
id_token String? @db.Text
* session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
@@map("accounts")
}14 Replies
@Mugger Crocodile Hiya,
I've recently been adding auth to my app, and now on the stage of adding oath. Because I was looking for a bit of a challenge, I decided to implement it myself with no AI, just raw oauth documentation and my own interpretation. So far its going really well however I've gotten to the point where I need to save the oauth data in my db. BUT, upon looking at the next-auth schema recommendation, I have no idea what some of the fields are meant to hold (i will mark with an *). if anyone can assist in explaining them to me, I would be more than grateful. Thanks.
js
model Account {
id String @id @default(cuid())
userId String @map("user_id")
* type String
* provider String
* providerAccountId String @map("provider_account_id")
refresh_token String? @db.Text
access_token String? @db.Text
expires_at Int?
* token_type String?
scope String?
id_token String? @db.Text
* session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
@@map("accounts")
}
it should be obvious, but:
provider: you must have setup google, it is to identify what provider, which could be google or your own site.
providerAccountId: Account id
just share your schema first
provider: you must have setup google, it is to identify what provider, which could be google or your own site.
providerAccountId: Account id
just share your schema first
and to identify what it means, try creating some users first, you can view the value and easily infer what it means
@Anay-208 can you share your next auth config
Mugger CrocodileOP
i'm not using next auth at all. i'm doing everything from scratch simply because why not.
i'm merely using its template
i was just asking because the google oauth api only returns the access_token, expires_in, scope, token_type, and id_token fields
so providerAccountId is the user id on the provider side, session_state is something provider like google provides
Mugger CrocodileOP
i'm assuming i have to fill the rest myself
so for type, its supposed to be like lets say you are using google oauth, you can put oauth
or email, credentials
for provider, just like google, github
and tokenType I'm not sure, but it should be like Bearer or smth like that
@Anay-208 and tokenType I'm not sure, but it should be like Bearer or smth like that
Mugger CrocodileOP
thought so
but thanks anyways