Тёмный

Connect Google Provider to Database - Next Auth 

Brett Westwood - Software Engineer
Подписаться 8 тыс.
Просмотров 11 тыс.
50% 1

#NextAuth #nextjs #mongodb
In this video, I go over how you can utilize the Google Provider from Next Auth and then being able to send that user's information (profile) to your MongoDB database.
This will allow you to keep a database full of users even if they log in with a OAuth Provider like Google.
If you enjoy content like this. Hit that like button and also subscribe to stay up-to-date.
Private 1 on 1 Help 👇
calendly.com/dabrettwestwood/...
Join my FREE Discord to talk and network about web development! 👇
/ discord
Time Stamps
0:00 Intro
0:12 Set up Environment
0:43 Create MongoDB Database
3:54 Adding Connection String/MONGO URI
4:56 Install necessary packages
5:44 Connect MongoDB Database with Mongoose
11:22 Start Setting up Next Auth
14:00 Get The Google Provider Keys
18:01 Continue Setting up Next Auth
25:52 User Schema Setup
28:54 Next Auth Connecting to Database
39:24 Outro

Хобби

Опубликовано:

 

22 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 55   
@madougi3
@madougi3 26 дней назад
someone get this guy an award
@ekchills6948
@ekchills6948 Год назад
This clarifies alot ❤
@monterourena
@monterourena Год назад
Best video I've seen about next-auth, really appreciate you explaining every detail of the callbacks
@brettwestwooddeveloper
@brettwestwooddeveloper Год назад
Thank you!
@DNAwastaken
@DNAwastaken Год назад
This is exactly what I needed! I was struggling with setting up NextAuth for MongoDB. Granted, I was using Prisma, and that was my first experience with it. Either way, thank you for this video!
@brettwestwooddeveloper
@brettwestwooddeveloper Год назад
Glad it helped!
@jamesfavour2957
@jamesfavour2957 Год назад
I love your video Sir. I’m currently building a shopping website for my business and your Nextauth tutorial is what I needed… you’ve got a subscriber ❤️❤️❤️ Looking forward to your videos on More Nextjs Videos
@brettwestwooddeveloper
@brettwestwooddeveloper Год назад
Glad it was helpful! Thanks for the sub!
@gromhellscream5581
@gromhellscream5581 10 месяцев назад
Another awesome video. Keep posting please!
@brettwestwooddeveloper
@brettwestwooddeveloper 10 месяцев назад
Thank you!
@gorkemgok9313
@gorkemgok9313 Месяц назад
You are a natural.
@brettwestwooddeveloper
@brettwestwooddeveloper 28 дней назад
Thank you I try to be!
@bilalshahid5118
@bilalshahid5118 5 месяцев назад
thankx bro it help me alot and I learned a lot from you
@brettwestwooddeveloper
@brettwestwooddeveloper 5 месяцев назад
No problem! Glad you liked it! I will be going live tonight as well if you need any help or just want to stop by!
@a.j999
@a.j999 10 месяцев назад
that's clear teaching thanks
@brettwestwooddeveloper
@brettwestwooddeveloper 10 месяцев назад
No problem! Thanks for tuning in!
@Sylar7773
@Sylar7773 Год назад
Thank You very mutch!!!
@brettwestwooddeveloper
@brettwestwooddeveloper Год назад
You're welcome! Thanks for the sub!
@textnow5752
@textnow5752 Год назад
Awesome Bro👍 keep it up 👍👍 #From_Kashmir India
@brettwestwooddeveloper
@brettwestwooddeveloper Год назад
Thanks
@gauravsharma4994
@gauravsharma4994 Год назад
Thankyou bro❤
@brettwestwooddeveloper
@brettwestwooddeveloper Год назад
You are welcome!
@rubenn6160
@rubenn6160 5 месяцев назад
thanks, i had a problem with nextauth, it said me access denied but the problem was in the function signin in [...nextauth] it not return a true value jjajaja
@panoscool_
@panoscool_ 10 месяцев назад
Hi Brett, your videos are great. I would suggest including typescript into your tutorials
@brettwestwooddeveloper
@brettwestwooddeveloper 10 месяцев назад
Thanks for watching and my newer videos will be inculding TypeScript
@raybenchen
@raybenchen 10 месяцев назад
How would you do if you need to add a GitHub or Facebook login and with their own respective callback logics, but one global callback function?
@tomasdavid1643
@tomasdavid1643 9 месяцев назад
Very good video thank you! Could you please provide some information on how to save refreshtoken? And how to rotate it if necessary?
@samking618
@samking618 10 месяцев назад
Hi, is there a way we can show a toast success message on successful sign in from google (or any other provider)? I have implemented it Credential Providers as the signIn() returns a promise in that case and we are allowed to do something like this, res = await signIn(), if res.error == null, toast.success(msg) but I am unable to do similar thing with providers like google any help would be appreciated
@kenthefley2226
@kenthefley2226 Год назад
It's weird that you posted this today. Yesterday I was thinking I need to ask you to make a video on authentication.
@brettwestwooddeveloper
@brettwestwooddeveloper Год назад
Just reading minds out here!
@himayukhan4659
@himayukhan4659 Год назад
I am having a user model which includes password also, scenerio is I am using both Google provider and credential provider, in my credentials I have two extra field.. Role:"user" and createdAt: "" what I did is in callbacks signin I want to add these two fields but now it is showing error that validation failed, pls enter your password, as Google does not send password in usessesion . Lmk how to handle this situation
@CedyBeato
@CedyBeato Год назад
Awesome! Can you make a part 2 of this? that when you successfully logged in it will redirect/connect to the home page with your name and avatar from your gmail. Thanks!
@brettwestwooddeveloper
@brettwestwooddeveloper Год назад
Yes I will do a video on that
@hhh.369
@hhh.369 2 месяца назад
It was a really helpfull video. I wanted to ask if I have login with credentials also than should I make the password optional in my postgres database.
@brettwestwooddeveloper
@brettwestwooddeveloper 2 месяца назад
I have two separate models one for user and one for account.
@therealdevopsintern
@therealdevopsintern Год назад
Please clarify this: you are using 'use client' how come your console log is logging out values on the server while indicating component as client side? I'm a bit confused here.
@brettwestwooddeveloper
@brettwestwooddeveloper Год назад
Yes if client side page then it would be in client console only and server side in the VSCode server
@user-op4hh8le6u
@user-op4hh8le6u 5 месяцев назад
After Sign in if we need to pass accessToken to external backend server build from node js to access protected routes then how will it works ?
@brettwestwooddeveloper
@brettwestwooddeveloper 4 месяца назад
If you want to pass properties like an accessToken then you will need to use the asynchronous callbacks that Next Auth provides you. I have a video of how to pass properties into these callbacks on my channel!
@priyankagoyal2969
@priyankagoyal2969 10 месяцев назад
sir it should be on git so that everyone can use this code
@essohanamalou7662
@essohanamalou7662 11 месяцев назад
great article. Am I missing something? Provider component has session as prop. So how are using Provider with undefined session and you are getting good results?
@brettwestwooddeveloper
@brettwestwooddeveloper 11 месяцев назад
the root layout file should have a session={session}. I guess mine somehow still worked in the video
@mubashirwaheed474
@mubashirwaheed474 9 месяцев назад
why aren't you using the mongodb adapter from the next-auth?
@brettwestwooddeveloper
@brettwestwooddeveloper 9 месяцев назад
I just didn't for this video, but I would recommend using the MongoDB adapter honestly.
@MrDzendzej
@MrDzendzej Год назад
On 9:20 the terminal is bloated with some weird warnings even tho everything should work ok. Do you know what are those and how to get rid of them? btw thanks for your work
@brettwestwooddeveloper
@brettwestwooddeveloper Год назад
yes i typed in npm run deb instead of npm run dev
@MrDzendzej
@MrDzendzej Год назад
@@brettwestwooddeveloper just before that you can see "import trace for requested module" warning. I meant this
@sinnis_879
@sinnis_879 11 месяцев назад
bro how can use Mysql instead of mongodb to store the user and session, please 😭
@brettwestwooddeveloper
@brettwestwooddeveloper 11 месяцев назад
Why?
@BillaSaheb786
@BillaSaheb786 Год назад
next with postgresql
@user-es2jt6qe2o
@user-es2jt6qe2o 9 месяцев назад
I dont want mongodb. I want postgres sir.. with love
@codewithsuslu
@codewithsuslu 4 месяца назад
But where is the role ? Admir or user ?
@brettwestwooddeveloper
@brettwestwooddeveloper 4 месяца назад
Not in this video
@codewithsuslu
@codewithsuslu 4 месяца назад
@@brettwestwooddeveloper well which video ?
@brettwestwooddeveloper
@brettwestwooddeveloper 4 месяца назад
@@codewithsuslu don't have a video about roles at the moment
Далее
Send Emails with Next.js 13 - The Best & Easiest Way
16:10
Qizim 58-qism | Anons |Nimaga meni bolam o'ladi ?
00:47
Next Auth and Prisma
12:45
Просмотров 14 тыс.
Next Js Firebase Auth  || Let google signin your users
47:03
Next Auth Sign in With Credentials
14:51
Просмотров 133 тыс.
Difference between cookies, session and tokens
11:53
Просмотров 603 тыс.
Auth.js V5 From Scratch
36:41
Просмотров 18 тыс.
#kidsong
0:11
Просмотров 29 млн
Что она делает?
0:34
Просмотров 11 млн
Вот так 🤣
0:35
Просмотров 1,9 млн
Beautiful gymnastics 😍☺️
0:15
Просмотров 14 млн