Skip to content
Init is coming / May 19 - 23
Back

oauth2 in nextjs app not working as it should

  • 0
  • Auth
  • Web
  • Cloud
KINGKabir👑
30 Apr, 2025, 09:47

for whole code view https://codeshare.io/5XYBMa

//app/store/auth.ts snippet for oauth2 async signInWithGoogle() {
const successUrl = 'http://localhost:3001/success'; const failureUrl = 'http://localhost:3001/login?error=oauth_failed'; try { await account.createOAuth2Session( OAuthProvider.Google, successUrl, failureUrl, ['profile', 'email'],); async handleOAuthCallback() {
try { const session = await account.getSession("current"); const user = await account.get<any>(); const { jwt } = await account.createJWT();

gettting errror result: Object { success: false, error: AppwriteException } ​ error: AppwriteException: User (role: guests) missing scope (account) ​ success: false

TL;DR
Issue with oauth2 in the Next.js app stemmed from missing user scope 'account' for guest role. Ensure the required scope is granted to the user role in the application. Solution: Grant the 'account' scope to the user role within the app configuration to resolve the error.
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