any one can help me?
TL;DR
The developers are facing an issue with 'general_unauthorized_scope' in their code related to authentication. The problem seems to stem from unauthorized access.
Solution:
Make sure that proper scopes are set for the OAuthProvider in the code for successful authentication.this is my code:
TypeScript
// lib/auth.ts
"use server";
import {
API_ENDPOINT,
API_KEY,
PROJECT_ID,
SESSION_COOKIE,
} from "@/config/appwrite";
import { Account, Client, OAuthProvider } from "node-appwrite";
import { cookies, headers } from "next/headers";
let appwriteClient = new Client()
.setEndpoint(API_ENDPOINT)
.setProject(PROJECT_ID)
.setKey(API_KEY);
let account = new Account(appwriteClient);
export async function getSession() {
const cookieStore = cookies();
const sessionId = cookieStore.get(SESSION_COOKIE)?.value;
if (!sessionId) {
return null;
}
try {
const session = await account.getSession(sessionId);
return session;
} catch (error) {
console.error("Failed to get session:", error);
return null;
}
}
export async function signIn(provider: "google") {
const origin = headers().get("origin") || "";
const success = `${origin}/api/auth/callback/${provider}`;
const failure = `${origin}/auth/error`;
const url = await account.createOAuth2Token(
OAuthProvider.Google,
success,
failure
);
return { url };
}
@Steven sorry for ping.. but did you have any solve?
i need help: general_unauthorized_scope
Recommended threads
- No server error on selfhosted appwrite
Please help me, my clients is ask what happen on their data? How can i make it up again?
- Upgrading selfhost version?
It is okay to upgrade version to higher one, of my current version is 1.7.4 to 1.8.1. Is that safe to do cause my clients already have data on that? Also is a...
- Magic Link token automatically consumed
Hi, I'm using the Magic Link auth system with Appwrite Cloud and I'm running into huge issues getting users to log in successfully. About 9 times out of 10, th...