kmΟShα
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. kmΟShα
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 };
}
kmΟShα
@Steven sorry for ping.. but did you have any solve?
kmΟShα
i need help: general_unauthorized_scope
Recommended threads
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...