# Nextjs 13 part 2: Authentication

**URL:** <https://forum.codewithmosh.com/t/nextjs-13-part-2-authentication/23264>\
**Category:** Next.js\
**Created:** [October 25, 2023, 2:50pm UTC](https://forum.codewithmosh.com/t/nextjs-13-part-2-authentication/23264 "2023-10-25T14:50:40Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dr.Press](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@Dr.Press](https://forum.codewithmosh.com/u/Dr.Press)\
**Post date:** [October 25, 2023, 2:50pm UTC](https://forum.codewithmosh.com/t/nextjs-13-part-2-authentication/23264/1 "2023-10-25T14:50:40Z")

</div>

I have configured every correctly on the google cloud environment and also code correctly. When I sign in, will receive an erorr saying “Try signing in with a different account”. I have created a new test user on the google cloud, but the situation remains the same. Any clue what is happening and how to fix this?

---

<div class="post-metadata">

**Author:** ![besart](https://avatars.discourse-cdn.com/v4/letter/b/aca169/32.png) [@besart](https://forum.codewithmosh.com/u/besart)\
**Post date:** [December 3, 2023, 5:55pm UTC](https://forum.codewithmosh.com/t/nextjs-13-part-2-authentication/23264/2 "2023-12-03T17:55:02Z")

</div>

Same here, did you find solution?

---

<div class="post-metadata">

**Author:** ![besart](https://avatars.discourse-cdn.com/v4/letter/b/aca169/32.png) [@besart](https://forum.codewithmosh.com/u/besart)\
**Post date:** [December 3, 2023, 6:24pm UTC](https://forum.codewithmosh.com/t/nextjs-13-part-2-authentication/23264/3 "2023-12-03T18:24:38Z")

</div>

**solved**

To address this, I updated the `@next-auth/prisma-adapter` dependency to the latest version. After updating, the issue was resolved, and authentication worked correctly.

To resolve this issue in your project, you can try updating the `@next-auth/prisma-adapter` dependency by running `npm update @next-auth/prisma-adapter`

---

<div class="post-metadata">

**Author:** ![sawfiz1](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@sawfiz1](https://forum.codewithmosh.com/u/sawfiz1)\
**Post date:** [January 5, 2024, 2:05am UTC](https://forum.codewithmosh.com/t/nextjs-13-part-2-authentication/23264/4 "2024-01-05T02:05:07Z")

</div>

I had the same issue, and came to the same solution.

As Mosh said, Next-auth is going through some transition, it is confusing as which library, @next-auth / @auth, and which version to use.

---

<div class="post-metadata">

**Author:** ![NKathome](https://avatars.discourse-cdn.com/v4/letter/n/85e7bf/32.png) [@NKathome](https://forum.codewithmosh.com/u/NKathome)\
**Post date:** [January 7, 2024, 1:53pm UTC](https://forum.codewithmosh.com/t/nextjs-13-part-2-authentication/23264/5 "2024-01-07T13:53:03Z")

</div>

I updated to the latest version of next-auth/prisma adatper (1.0.7) and I am still unable to log in. Any other ideas would be appreciated. Thank you.

---

<div class="post-metadata">

**Author:** ![NKathome](https://avatars.discourse-cdn.com/v4/letter/n/85e7bf/32.png) [@NKathome](https://forum.codewithmosh.com/u/NKathome)\
**Post date:** [January 15, 2024, 2:03pm UTC](https://forum.codewithmosh.com/t/nextjs-13-part-2-authentication/23264/6 "2024-01-15T14:03:42Z")

</div>

I thought I’d try one more time to get this issue resolved. I have updated to the latest version of the next-auth prisma adapter.

Everything works if I disable the adapter by updating the auth route to look like this:

```auto
import NextAuth from "next-auth/next";
import GoogleProvider from "next-auth/providers/google"
import { PrismaAdapter } from "@next-auth/prisma-adapter";
import prisma from '@/prisma/client'
import { NextAuthOptions } from "next-auth";

export const authOptions:NextAuthOptions = {
  //adapter: PrismaAdapter(prisma),
  providers:[
    GoogleProvider({
      clientId: process.env.GOOGLE_CLIENT_ID!,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET!
    })
  ],
  //session: {strategy:'jwt'}
};

const handler = NextAuth(authOptions);

export {handler as GET, handler as POST}

```

As you can see, I commented out the lines that configure the adapter. With this change I can log into the app with my GMail account. But I’d like to get the adapter to work.

Any advice would be much appreciated, thanks!

---

<div class="post-metadata">

**Author:** ![bnazeem](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@bnazeem](https://forum.codewithmosh.com/u/bnazeem)\
**Post date:** [January 24, 2024, 2:56am UTC](https://forum.codewithmosh.com/t/nextjs-13-part-2-authentication/23264/7 "2024-01-24T02:56:54Z")

</div>

I updated to the latest version of next-auth/prisma adatper (1.0.7) and I am still unable to log in. Any other ideas would be appreciated. Thank you.

---

<div class="post-metadata">

**Author:** ![polycozy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/polycozy/32/7703_2.png) [@polycozy](https://forum.codewithmosh.com/u/polycozy)\
**Post date:** [January 31, 2024, 4:41am UTC](https://forum.codewithmosh.com/t/nextjs-13-part-2-authentication/23264/8 "2024-01-31T04:41:32Z")

</div>

Alright, guys, I nailed it.

First, you have to make sure `@next-auth/prisma-adapter` is up to date (as of today it’s 1.0.7)  
Then, make sure you copy the schema from the new Auth.js site. ([here](https://authjs.dev/reference/adapter/prisma?_gl=1*tzcxu0*_gcl_au*OTM3OTIyMzkzLjE3MDY2NzIxOTk.)) Not the old Next-Auth site, there are some teeny-tiny difference that would cause some mySQL errors. If you have already run prisma migration as per the video at this point, don’t worry just delete the last migration folder, paste the new schema and overwrite, then run the migration again.  
Finally, I did these things in these orders: rerun npm run dev, go to cookies and clean the localhost:3000, go to signout page and signout, go to signin page and sign in. Boom, I’m in.

Hope this helps. Cheers:)

---

<div class="post-metadata">

**Author:** ![bnazeem](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@bnazeem](https://forum.codewithmosh.com/u/bnazeem)\
**Post date:** [January 31, 2024, 10:59pm UTC](https://forum.codewithmosh.com/t/nextjs-13-part-2-authentication/23264/9 "2024-01-31T22:59:15Z")

</div>

Thanks @polycozy, it worked. Not sure what was the issue, I tried several times, several days, but was not working.

---

<div class="post-metadata">

**Author:** ![agorakis](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/agorakis/32/7738_2.png) [@agorakis](https://forum.codewithmosh.com/u/agorakis)\
**Post date:** [February 8, 2024, 11:07am UTC](https://forum.codewithmosh.com/t/nextjs-13-part-2-authentication/23264/10 "2024-02-08T11:07:24Z")

</div>

Hi guys i tried all the solutions but still the issue remains. actually i cant continue with course due to this. Any solution?

---

<div class="post-metadata">

**Author:** ![SilviuJS](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/silviujs/32/7851_2.png) [@SilviuJS](https://forum.codewithmosh.com/u/SilviuJS)\
**Post date:** [March 17, 2024, 11:57am UTC](https://forum.codewithmosh.com/t/nextjs-13-part-2-authentication/23264/11 "2024-03-17T11:57:49Z")

</div>

Hello, I also updated to latest version of @next-auth/prisma-adapter and still not working, please help

---

<div class="post-metadata">

**Author:** ![SilviuJS](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/silviujs/32/7851_2.png) [@SilviuJS](https://forum.codewithmosh.com/u/SilviuJS)\
**Post date:** [March 17, 2024, 12:05pm UTC](https://forum.codewithmosh.com/t/nextjs-13-part-2-authentication/23264/12 "2024-03-17T12:05:12Z")

</div>

Ok, I got it to work:

Make sure that if you modify the schema.prisma file you run again the command ‘npx migrate prisma dev’ in order to push the changes to the DB
