Faye
Heyo,
I am getting: AppwriteException: Invalid redirect
in this code:
TypeScript
'use server'
import { createAdminClient } from '@/app/appwrite-session'
import { redirect } from 'next/navigation'
import { headers } from 'next/headers'
export async function loginWithOAuth2(provider: any) {
const { account } = await createAdminClient()
const origin = headers().get('origin')
console.log(origin)
const redirectUrl = await account.createOAuth2Token(
provider,
`${origin}/api/user/oauth`,
`${origin}/login?failure=true`
)
return redirect(redirectUrl)
}
Would someone know why? 🤔 Coming from this: https://appwrite.io/docs/tutorials/nextjs-ssr-auth/step-7#oauth-server-action
TL;DR
Issue: Developer is receiving an `AppwriteException: Invalid redirect` error on the `account.createOAuth2Token` function in their code.
Solution: Make sure the redirect URLs provided in the `account.createOAuth2Token` function match the allowed redirect URIs in your OAuth provider settings. Recommended threads
- 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 ...
- Get team fail in appwrite function
I try to get team of a user inside appwrite function, but i get this error: `AppwriteException: User (role: guests) missing scope (teams.read)` If i try on cl...