Back

AppwriteException: User (role: guests) missing scope (account)

  • 0
  • Auth
  • Web
  • Cloud
vishwa
16 Mar, 2024, 08:13

is AppwriteException: User (role: guests) missing scope (account) at l.<anonymous> (https://patiyala.vercel.app/_next/static/chunks/169-669b8aff7908ca0e.js:38:8845) at Generator.next (<anonymous>) at a (https://patiyala.vercel.app/_next/static/chunks/169-669b8aff7908ca0e.js:38:2628) page-568c20c68195f2df.js:1

this error occurs only in vercel and doesnt occur in localhost when the user tries to login via google and is redirected afterlogin. Please help.

TL;DR
Developers are facing an "AppwriteException: User (role: guests) missing scope (account)" error when trying to access a project. The issue seems to be related to browser settings blocking third-party cookies. They are seeking a code-based solution as enabling settings may not be feasible for all users.
vishwa
16 Mar, 2024, 08:15

@Moderator

vishwa
16 Mar, 2024, 08:15

Could someone help me. it was working just a moment ago and now it doesnt

vishwa
16 Mar, 2024, 08:27

{ "message": "User (role: guests) missing scope (account)", "code": 401, "type": "general_unauthorized_scope", "version": "0.12.121" }

vishwa
16 Mar, 2024, 08:54

sessions are getting created though

D5
16 Mar, 2024, 09:58

SSR support comes with 1.5. Cloud is for now in 1.4

vishwa
16 Mar, 2024, 09:59

Oh

vishwa
16 Mar, 2024, 09:59

so what do i do now?

vishwa
16 Mar, 2024, 10:01

The problem is only with google auth and normal sign up works just fine

vishwa
16 Mar, 2024, 10:04

Hey could you please help me out and maybe provide me with a tutorial or documentation which implements google auth on next js with appwrite?

vishwa
16 Mar, 2024, 10:25

const currentSession =async()=>{ try{ const session = await account.get();

TypeScript
console.log(session);
console.log(session.userId);
setLoggedInUser(session)

console.log(session.providerEmail);

}

TypeScript
catch(err){
  console.log(err)

}

} this is how i am trying to find the user's account which is logged in. this works just fine on local host but doesnt work on the vercel app

D5
16 Mar, 2024, 10:41

"use client";

vishwa
16 Mar, 2024, 10:46

Hey thanks a lot, but as i told the normal login does work for me its just that google auth is not

vishwa
16 Mar, 2024, 10:46

the account and the sessions are getting created its just that on redirect it says that AppwriteException: User (role: guests) missing scope (account) and couldnt get the logged in account info

vishwa
16 Mar, 2024, 10:47

Please help me out with this one

D5
16 Mar, 2024, 10:53

Do you have added the use client in oauth?

vishwa
16 Mar, 2024, 11:10

yes

Guille
16 Mar, 2024, 13:40

How are you handling the success URL of the oauth2?

vishwa
16 Mar, 2024, 16:05

So i have a function which will check if the users account is used for the first time and then it is pushed db with the basic info of the user

vishwa
18 Mar, 2024, 17:08

Hey i am still facing the same issue. Could anyone help me pls?

vishwa
18 Mar, 2024, 17:10

: (

malix.com
18 Mar, 2024, 17:44

Using this works.

TypeScript
'use client'; // ESSENTIAL!

import { createWebClient } from '@/api/database/createWebClient';

export async function getWebLoggedInUser() {
  const { account } = createWebClient();
  try {
    return await account.get();
  } catch (e) {
    return null;
  }
}
malix.com
18 Mar, 2024, 17:47
TypeScript

export function createWebClient() {
  const client = new Client()
    .setEndpoint('https://cloud.appwrite.io/v1')
    .setProject('YOUR_PROJECT');

  return {
    get account() {
      return new Account(client);
    }
  };
}

export const ID = AID;
D5
18 Mar, 2024, 18:00

What's the browser you're using?

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