Next JS Authentication - Sign In With Google (NextAuth.js)

  Рет қаралды 70,731

Code Commerce

Code Commerce

Күн бұрын

Пікірлер: 183
@codecommerce
@codecommerce 2 жыл бұрын
🏆 generate-secret.vercel.app/32 (Generate Key)
@arisudana3672
@arisudana3672 2 жыл бұрын
This content saved my life as a beginner dev, thank you so much King!
@codecommerce
@codecommerce 2 жыл бұрын
Thank you my friend!
@elijah_10000
@elijah_10000 Жыл бұрын
You're a livesaver. Best video I've seen surrounding the topic. I loved how you showed multiple ways to do things, and how you covered every edgecase. Really helpful video :)
@codecommerce
@codecommerce Жыл бұрын
Thanks Elijah
@ThanhNguyen-xe1zs
@ThanhNguyen-xe1zs Жыл бұрын
You make it easier for me, i have been following you, thank you!
@codecommerce
@codecommerce Жыл бұрын
You are so welcome!
@leanhtung9743
@leanhtung9743 2 жыл бұрын
I am on new job and working mainly with Nextjs and I gotta say i'm waiting for your new videos daily since I applied almost everything you upload on my job =))))) so Thanks!!!!
@hoobmuffin
@hoobmuffin Жыл бұрын
Thanks for not overcomplicating the demo with tons of unnecessary stuff like the rest of these guys do.
@lucifer3646
@lucifer3646 Жыл бұрын
You deserve millions man. Thank you for your videos.
@codecommerce
@codecommerce Жыл бұрын
Thank you dude! 🙏
@Odidi_Bee6ix
@Odidi_Bee6ix Жыл бұрын
Thanks cheif 👍🏿❤️ Beginner friendly
@barehandstudio
@barehandstudio Жыл бұрын
thank you for you video, i have been stuck on next auth for a while now. your are awesome
@codecommerce
@codecommerce Жыл бұрын
Thank you my friend!
@danielsoto2552
@danielsoto2552 Жыл бұрын
I had troubles using Google Api in a different language (german) as the menu is completely different, changed to english, all great now. Thanks for the step by step tutorial!
@plotitsyn
@plotitsyn Жыл бұрын
Great video! Thanks!
@codecommerce
@codecommerce Жыл бұрын
Thank you!
@Koxy_Dev
@Koxy_Dev 9 ай бұрын
This was very helpful. Thank you.
@MehdiMehdi-wp4wm
@MehdiMehdi-wp4wm Жыл бұрын
Hi, i am getting this:"Error: [next-auth]: `useSession` must be wrapped in a
@JustSkillGG
@JustSkillGG 2 жыл бұрын
I am really glad that I discovered your channel. Awesome videos and awesome explaining. One year later, when this channel would have 200k subs, I will make the comment "I was a subscriber from 6k :D " Keep it up, man! You got this
@codecommerce
@codecommerce 2 жыл бұрын
Haha you’re the man!! Thanks dude!
@harshafartale5775
@harshafartale5775 2 жыл бұрын
Much needed! ❤️
@codecommerce
@codecommerce 2 жыл бұрын
Thank you harsha!
@guilhermelopes7939
@guilhermelopes7939 2 жыл бұрын
Thank you for such an important tutorial, congrats from Brazil.
@dhriti3080
@dhriti3080 Жыл бұрын
You are awesome man. Thanks a lot for this video.
@richleach198
@richleach198 2 жыл бұрын
Well done Clint, thank you for the video.
@codecommerce
@codecommerce 2 жыл бұрын
Thank you Rich!
@ghislainmitahi2584
@ghislainmitahi2584 Жыл бұрын
I love it dear, Big Up to you, Be blessed
@chillscripter
@chillscripter 2 жыл бұрын
i did the exact same steps but didn't got the same result . I don't know why , it's the same version of next-auth same code and at the end different result . the problem is when i signin and enter my Gmail , my website take the Gmail but after a few sec it'll show a message that say's try with another account and there's button for clicking to enter your another acc but it'll just stick to same page and when i check it from network tab it just send different cookies to the URL . don't know what's the problem and where am i making mistake , any help would be appreciated
@barehandstudio
@barehandstudio Жыл бұрын
same error here, where you able to fix this ?? please help
@sarvenazranjbar6672
@sarvenazranjbar6672 Жыл бұрын
Thank youu saved my life!
@luisbarbosa5597
@luisbarbosa5597 2 жыл бұрын
always my go to vid, most effective
@y2b5
@y2b5 Жыл бұрын
Works well, thank you so much!
@codecommerce
@codecommerce Жыл бұрын
Thank you Daphne!
@maratiot
@maratiot 2 жыл бұрын
Awesome and helpful content! You are good bro!
@timofeybabisashvili7077
@timofeybabisashvili7077 Жыл бұрын
great, works! Thank you
@elisperezmusic
@elisperezmusic Жыл бұрын
thanks!! Excellent video..! 🤯🤯🤯
@toainguyencong3811
@toainguyencong3811 Жыл бұрын
nice man
@lukasmacku2423
@lukasmacku2423 Жыл бұрын
Thank you so much! I need someone like you to explain me how to do it. I was looking at the ofc docs but I did not get why I have to use ENV and google. I though that it is only for idk what i was thinking. The important thing is that i now know how to implement it. Ty :)
@codecommerce
@codecommerce Жыл бұрын
Thank you sir!
@fgalego
@fgalego 2 жыл бұрын
Also "How to build/have an awesome web dev learning YT channel"! Keep it up chief, learning has never been so good and easy like here 👌
@codecommerce
@codecommerce 2 жыл бұрын
Thank you Filipe!
@tranxuantien1495
@tranxuantien1495 Жыл бұрын
i'm using page.tsx + layout.tsx structure. Where can i put the seesion provider?
@josephomotade864
@josephomotade864 2 жыл бұрын
you are making web development so easy 😁 thanks man
@codecommerce
@codecommerce 2 жыл бұрын
Joseph! You are the man!
@davidofug
@davidofug 2 жыл бұрын
Wonderful tutorial man! I was able to implement everything here now, I need to redirect after successful login. Thank you
@codecommerce
@codecommerce 2 жыл бұрын
So awesome man, thank you for the support 🙏
@adhdmed
@adhdmed 2 жыл бұрын
Amazing much needed tutorial.
@codecommerce
@codecommerce 2 жыл бұрын
Glad it was helpful! Thank you Faeez
@flor.7797
@flor.7797 Жыл бұрын
thank you, this worked very well
@alii4334
@alii4334 Жыл бұрын
How to handle preview urls programmatically with Google?
@emersonxyz
@emersonxyz Жыл бұрын
you remind me of cutter from masterchef. btw great tutorial
@princeakim01
@princeakim01 Жыл бұрын
thanks very much from Burkina Faso
@mohammadnizarardansyah7657
@mohammadnizarardansyah7657 Жыл бұрын
thanks buddy, this video so helpfull
@mord685
@mord685 Жыл бұрын
Hi Code Commerce, what version of yarn do use to generate the pages, public, and styles directories?
@adityadubey4578
@adityadubey4578 Жыл бұрын
This was very very helpful man, thanks a lot 😃
@BabaNoami
@BabaNoami 2 жыл бұрын
Good stuff. Was getting stuck how to set it up right. Thanks!
@codecommerce
@codecommerce 2 жыл бұрын
Awesome Noam!
@oldmandevdave
@oldmandevdave Жыл бұрын
Really helpful. Thanks!!!
@codecommerce
@codecommerce Жыл бұрын
Thank you Dave!
@kman1111000
@kman1111000 Жыл бұрын
Very helpful video, thanks man
@codecommerce
@codecommerce Жыл бұрын
Thanks Kody!
@renaud689
@renaud689 2 жыл бұрын
Great tuto thanks !
@codecommerce
@codecommerce 2 жыл бұрын
Thank you sir
@odetapenikaite4339
@odetapenikaite4339 Жыл бұрын
To anyone that got a different screen when tried to create credential: you need to first set up the OAuth consent screen. After that you are able to go on and create the credentials :)
@codecommerce
@codecommerce Жыл бұрын
Thank you odeta
@vraj2003
@vraj2003 2 жыл бұрын
Hey Sir, Please upload the same video with using JWT token rather than Session.
@niteshprajapat7918
@niteshprajapat7918 2 жыл бұрын
You're incredible ❤️🔥
@codecommerce
@codecommerce 2 жыл бұрын
Nitesh! What is up man!
@asifsaho
@asifsaho Жыл бұрын
how backend will understand the fronend is logged in? is there JWT token or something? how the backend will verify it before returning any data?
@andrewwachira1
@andrewwachira1 2 жыл бұрын
Thanks for the video brother. You helped me out big time.
@codecommerce
@codecommerce 2 жыл бұрын
Anytime dude! Thank you for watching!
@gnumanoj
@gnumanoj Жыл бұрын
Thank you so much !!!
@youneshenni5417
@youneshenni5417 2 жыл бұрын
This is soooo goooood !!!!
@codecommerce
@codecommerce 2 жыл бұрын
Thanks dude!
@siosaiafonua9286
@siosaiafonua9286 2 жыл бұрын
How do you redirect to the account page after signing in to google or github?
@filipevalentegomes2383
@filipevalentegomes2383 2 жыл бұрын
Hey, do you have a Next.js Firebase v9 CRUD with file upload tutorial? There aren't many tutorials or even courses on it, where the uploaded files are linked to the user that signed in and uploaded the files.
@codecommerce
@codecommerce 2 жыл бұрын
That would be cool! We can do a Firebase file upload with react!
@saphalpantha9865
@saphalpantha9865 Жыл бұрын
This is so nice but i have some query that for normal credentials provider it works fine , store data in db but using 3rd party providers how can we access the password and store to database when the user click sign in with google/fb.
@arshah246
@arshah246 Жыл бұрын
hello friends i am using next js 13.4 i have set up my credentials on google auth but when i click on sign in button it leads me to 404 page i think its due to api/auth/callback/google page because there is no page in my file , but in the given video it is also not available then why video's code is working and mine is not can anyone please guide or suggest me something thanks in advance with love from pakistan
@PeopleWatchingMarcus
@PeopleWatchingMarcus Жыл бұрын
same issue
@PeopleWatchingMarcus
@PeopleWatchingMarcus Жыл бұрын
Ok, so this is a next 13 issue. rename `[...nextauth].ts` to `route.ts` and put in the `[...nextauth]` directory update this file to ``` const handler = NextAuth({ providers: [ GoogleProvider({ clientId: process.env.GOOGLE_ID ?? "", clientSecret: process.env.GOOGLE_SECRET ?? "", }), ], secret: process.env.JWT_SECRET, }); export { handler as GET, handler as POST }; ```
@EnriqueMoranG
@EnriqueMoranG 2 жыл бұрын
You're amazing!!
@codecommerce
@codecommerce 2 жыл бұрын
You’re the man!
@justrandom7412
@justrandom7412 Жыл бұрын
May I know how to force the signin to choose an email everytime I login? In 22:53, it auto logs in all through out
@saikrishnamuntha62
@saikrishnamuntha62 9 ай бұрын
Hi bro how to set the default page to be login when go to npm run dev in the browser it to be handle localhost:3000/login not the home page localhost:3000 I implemented but when I gave localhost:3000 its changing to localhost:3000/login but the issue is white space occuring 2secs then login page occuring how to resolve this issue
@durotemy8410
@durotemy8410 6 ай бұрын
thanks bro...but for small project like this u should pls drop ur github repo
@vraj2003
@vraj2003 2 жыл бұрын
Hey Please Reply, How do I remove black screen before user is signin in?
@vraj2003
@vraj2003 2 жыл бұрын
No worries, I have to add provider name inside signIn() function call, in this case, google. if anyone want to do the same. Replace ()=>signin() with ()=>signIn('google') Btw, Thank you sir for this amazing tutorial
@codecommerce
@codecommerce 2 жыл бұрын
Thank you Vraj! I’ll pin this!
@dini.alejandro.eyecue
@dini.alejandro.eyecue Жыл бұрын
Thanks, man! Any tip on how to use the server-side version but for all the routes (except /login) at once?
@oldmandevdave
@oldmandevdave Жыл бұрын
so now that we have logged in, how do we get resources from a protected api? Example we login as admin and we want to perform CRUD ops on products. Springboot preferred but any back end language.
@danielbaychev9297
@danielbaychev9297 Жыл бұрын
is it possible to customize that black page with the login button?
@DesertWebDev
@DesertWebDev Жыл бұрын
love the video. can you make a video about how to add extended user data? like a favorite color or a custom username other than the provider username?
@domistry
@domistry Жыл бұрын
That was awesome, thanks bro; can you please share google's authentication page customization options?
@renatoAllArt
@renatoAllArt Жыл бұрын
thanks dude
@beno_zone6
@beno_zone6 2 жыл бұрын
Very helpful
@codecommerce
@codecommerce 2 жыл бұрын
Thank you!
@tolu.olunubi
@tolu.olunubi Жыл бұрын
Thank You
@photoshopkbshorts1
@photoshopkbshorts1 2 жыл бұрын
merci beaucoup a toi :))
@mauroreis1809
@mauroreis1809 2 жыл бұрын
It works fine with localhost but after i finished my site and push it to production, i can't authenticate "Error 400: redirect_uri_mismatch". And yes, i changed the .env and also the settings in the google cloud console. I have been stuck with this problem for 3 days or so and it's the last project for my portfolio.
@sandeshsapkota3375
@sandeshsapkota3375 2 жыл бұрын
Hi Thank you for the video. I am looking to implement sign in with pop up not the redirect on the another page and also want to avoid second time sign in with google button . how do I do it ?
@rolandocruz1695
@rolandocruz1695 Жыл бұрын
Loved the video! this was super useful! I'm just a little confused what I should do with the JWT token? do i need that for production?
@luzaw4957
@luzaw4957 Жыл бұрын
Do you mean JWT secret? It's a 32 bit key that Next Auth needs it to issue and verify JWT.
@jamesrobert5332
@jamesrobert5332 2 жыл бұрын
I am persisting the user in a database using the adapters, what I'm trying to figure out is how to make a user choose which google account they want to sign in with because after they sign in with a certain account the first time, everytime they try to sign in with google it will sign them in using the same initial account, but I want to bring up that window that asks them which google account they want. Any ideas or insight on this?
@ron-almog
@ron-almog 2 жыл бұрын
Awsome! I wish it would be in typescript, but a great starting point anyways.
@codecommerce
@codecommerce 2 жыл бұрын
We can do typescript! Thank you
@Khaalid_JSX
@Khaalid_JSX Жыл бұрын
I was following your tutorial but I keep get a prompt on the Google sign page anytime I clicked on the sign in with Google button to "To sign in with a different account"
@Rikimkigsck
@Rikimkigsck Жыл бұрын
An updated video would be great
@codecommerce
@codecommerce Жыл бұрын
Nextjs 13 - kzbin.info/www/bejne/iZDWh2mYjrx-jrM
@Rikimkigsck
@Rikimkigsck Жыл бұрын
@@codecommerce Thank you! Liked and Subscribed
@IanCostello1
@IanCostello1 Жыл бұрын
Legend
@codecommerce
@codecommerce Жыл бұрын
Thanks dude - much love! 💪
@tikitokz3742
@tikitokz3742 Жыл бұрын
Hi , I've qus i got this ERROR while im using your code (ERROR : expected 200 OK, got: 403 Forbidden) and in my chrome page i got ERROR (Try signing in with a different account.) I can't FIX ⛔⛔How can i FIX ??
@aquilabdullah
@aquilabdullah 2 жыл бұрын
This was a great tutorial, but how do you get and store the access token and refresh token from the account, when you signin?
@Code_Prince
@Code_Prince Жыл бұрын
I'm using Next 13.4.4 and dont have _app.js file and keep getting this error Error: [next-auth]: `useSession` must be wrapped in a Tried everythign, read everywhere and still and issue need help please
@codecommerce
@codecommerce Жыл бұрын
Try to wrap in the page.js or index
@johnthomas1833
@johnthomas1833 Жыл бұрын
Can this be used with React js application ?
@가나다-x1r7o
@가나다-x1r7o Жыл бұрын
thank you
@outplay3759
@outplay3759 2 жыл бұрын
Hi, very nice content, thank you. I have a question: As you can see you get a flash of the page before it redirects you to the log in page when you try to access the page while you are not logged in. When you implemented the serverSideProps, the flash was removed. I tried to google this and what I found was that if I don't want the flash of the unauthorized page to happen, I have to use the serverSideProps on those pages. Does this mean if I have authentication I cant pre-render pages with static props if I dont want the contect to be flashed to the users who are not logged in? I am new to this so I may be way off with my logic :D
@markchang1762
@markchang1762 Жыл бұрын
If I remember correctly, static props are for build time whereas serverSideProps are for fetching at request time. Authentication changes and you need to validate at the time when someone request a page
@EmmanuelAyetan
@EmmanuelAyetan Жыл бұрын
What about the adapter?
@Troy-ol5fk
@Troy-ol5fk 2 жыл бұрын
why is the jwt secret a env variable? I thought each user will get a unique token
@obey_giant
@obey_giant 2 жыл бұрын
How would you make a custom sign in page, styled exactly how you want instead of the plain sign in with google page?
@codecommerce
@codecommerce 2 жыл бұрын
About to pin some useful content tonight!
@eventsjamaicamobileapp1426
@eventsjamaicamobileapp1426 Жыл бұрын
I keep getting "missing required error components, refreshing..." in the local broswer
@yousafwazir3167
@yousafwazir3167 2 жыл бұрын
Thanks this helped out so much, could you do a adapters one with prisma and postgres sql as I find that really hard
@codecommerce
@codecommerce 2 жыл бұрын
Thank you Yousaf!
@luisbarbosa5597
@luisbarbosa5597 2 жыл бұрын
nice bruh
@anjanobalesh8046
@anjanobalesh8046 Жыл бұрын
I think this holds good for onekkhon sso also
@theavazov
@theavazov Жыл бұрын
Good content, can you tell me how to redirect user after login with google from "/login" to "/account"?
@RahulShinde
@RahulShinde Жыл бұрын
Hi Code Commerce I got below error message, while trying to sign in. It occur random time but most of the time failed Try signing in with a different account.
@sanwaniwani5072
@sanwaniwani5072 Жыл бұрын
you got have solve?
@jorgeassaf
@jorgeassaf 2 жыл бұрын
hello brother, in a video I could explain the authentication with react and supabase. good video
@codecommerce
@codecommerce 2 жыл бұрын
Thank you Jorge
@realtonaldrum
@realtonaldrum Жыл бұрын
does it make any difference to use .env.local instead of .env as file in the ./-folder?
@manny8816
@manny8816 Жыл бұрын
No, it shouldn't
@bafxyz
@bafxyz 2 жыл бұрын
Good video, would be great to see github link as well
@codecommerce
@codecommerce 2 жыл бұрын
I can add that!
@EmmanuelAyetan
@EmmanuelAyetan Жыл бұрын
What about the database?
@Нннн-г3й
@Нннн-г3й 2 жыл бұрын
how to get id token. i want to verify token on server and give from server access token for client. sorry i use google translate, i dont speak english
@JBUDDTV
@JBUDDTV Жыл бұрын
could you do level access with this method like admin and user?
@codecommerce
@codecommerce Жыл бұрын
Yes you can add user specific rules.
@popalopagos
@popalopagos Жыл бұрын
Is there any way to have local & prod both functioning simutaniously? It's kind of a deal breaker if I want to debug local and then take down prod. EDIT: Just realised I can probably make 2 apps and then switch between them depending on environment.
@coffeymay6775
@coffeymay6775 Жыл бұрын
Research CI/CD
@mohitpunia6245
@mohitpunia6245 2 жыл бұрын
I am getting [error][CALLBACK_OAUTH_ERROR] and JWT expired ,,,,,I did same code as you have done , can you tell what should i do
@codecommerce
@codecommerce 2 жыл бұрын
1) Check my code out on GitHub 2) Check Firebase to make sure you have your auth set up correctly
Authentication Flow in Next.js (Complete Tutorial)
30:37
Cosden Solutions
Рет қаралды 18 М.
Set up Google OAuth with Next.js using Next-Auth!
21:00
Build SaaS with Ethan
Рет қаралды 29 М.
HELP!!!
00:46
Natan por Aí
Рет қаралды 54 МЛН
ЛУЧШИЙ ФОКУС + секрет! #shorts
00:12
Роман Magic
Рет қаралды 30 МЛН
ROSÉ & Bruno Mars - APT. (Official Music Video)
02:54
ROSÉ
Рет қаралды 323 МЛН
БУ, ИСПУГАЛСЯ?? #shorts
00:22
Паша Осадчий
Рет қаралды 1,9 МЛН
Next JS Authentication - Sign In With Github (NextAuth.js)
19:11
Code Commerce
Рет қаралды 12 М.
Next.js 13 Role Based Authorization with Middleware & NextAuth
17:04
Tuomo Kankaanpää
Рет қаралды 22 М.
Build A NEXT JS Weather App - OpenWeatherMap API - Tutorial
49:14
Code Commerce
Рет қаралды 20 М.
Learn Next.js 15 in 1 hour - Beginner Tutorial
59:25
Codevolution
Рет қаралды 27 М.
HELP!!!
00:46
Natan por Aí
Рет қаралды 54 МЛН