Back

Any working example for nextjs using google Oauth? I struggle in the last week to create progress

  • 0
  • Web
adminini
4 Sep, 2023, 20:25

I was able to add users, but it won't get in to the callback of success. It throws: Error fetching user: AppwriteException: User (role: guests) missing scope (account)

It's self-hosted with coolify (1.4)- the google console is configured. I tried to give it localhost "http://localhost:3000/callback" endpoint

Any working example for a dashboard (behind login with google) that serve api function in appwrite? it will be great start. I scanned all the internet and didn't found something good.

TL;DR
User is struggling to create a Next.js project with Google OAuth and Appwrite. They have questions about configuring the API key, sessions, CNAME, and using the functionality of the API key without server side. They also ask about using Next.js for projects and hiding server functions, as well as implementing payment mechanisms and SEO. They mention a 401 Unauthorized error and ask for help monitoring the issue. They wonder if they should use React instead of Next.js and ask for a minimal working example. They mention an error when adding users and share the details. They also inquire about a working example of a dashboard behind a Google login using Appwrite
Drake
4 Sep, 2023, 21:08

are you using server side rendering? That could be a problem because a session would be created client side which doesn't exist server side

adminini
4 Sep, 2023, 21:27

I tried both, are you familiare with minimal working example?

adminini
4 Sep, 2023, 21:27

or maybe i should use it only with REACT instead of nextjs project?

Drake
4 Sep, 2023, 21:33

It would be best to avoid using SSR.

Besides that, another problem you could be facing is 3rd party cookies. To fix that, you can enable 3rd party cookies in your browser or configure custom domains https://appwrite.io/docs/custom-domains

adminini
4 Sep, 2023, 22:00

Thanks for the tips! I'll try them. is there anyway to monitor that this is the problem?

Drake
4 Sep, 2023, 22:02

check the network request in the browser network logs and in the cookies tab for the api call. you may see that the browser says some are blocked due to 3rd party cookie

adminini
4 Sep, 2023, 22:08

is that a symptom for that? Status 401 Unauthorized VersionHTTP/2 Transferred1.15 kB (122 B size) Referrer Policystrict-origin-when-cross-origin DNS ResolutionSystem

adminini
4 Sep, 2023, 22:09

(it is from my host in XX.my-domain.com where appwrite is selfhosted)

adminini
4 Sep, 2023, 22:16

This is the screenshot of the logs if it might help (back...) is the appwrite on my domain

Drake
4 Sep, 2023, 22:27

could be yes

adminini
4 Sep, 2023, 22:31

thanks. so is there a point in working in nextjs for doing projects with nextjs? maybe just to hide the server function sometimes? maybe with payment mechanism?

Drake
4 Sep, 2023, 22:32

maybe if you have some page that needs SEO?

or you could make use of the server routes, but you'll need ot make sure to handle sessions somehow

adminini
4 Sep, 2023, 23:11

Yea seems right.

adminini
4 Sep, 2023, 23:11

But tell me, how can i use the functionality of the api-key of appwrite without server side?

adminini
4 Sep, 2023, 23:54

regarding the CNAME- what address should i put? the localhost?

Drake
5 Sep, 2023, 00:34

The API key is only used server side. Sessions aren't used with the node SDK

Drake
5 Sep, 2023, 00:34

It should be your domain

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more