Back

[SOLVED] Getting an error with google auth

  • 1
  • Auth
  • Web
  • Cloud
Kenny
17 Sep, 2024, 14:13

Have you tried anything else with your appwrite client, like fetching documents?

TL;DR
Developers were having issues with Google authentication but it's now solved. The problem was related to setting up environment variables correctly. The error occurred due to an invalid URL when creating an OAuth2 session. They needed to ensure the URL was properly formatted for it to work.
NHero
17 Sep, 2024, 14:13

no not yet

Kenny
17 Sep, 2024, 14:14

What URL are you using when initializing your client?

NHero
17 Sep, 2024, 14:14
Kenny
17 Sep, 2024, 14:15

Can you send a snippit of your client code? Are you using environment variables?

NHero
17 Sep, 2024, 14:15

yes im using env

TypeScript
import env from "@/env";
import { Client, Account, Avatars, Databases, Storage, OAuthProvider } from "appwrite";

const client = new Client()
  .setEndpoint(env.appwrite.endpoint)
  .setProject(env.appwrite.projectId);

const databases = new Databases(client);
const account = new Account(client);
const avatars = new Avatars(client);
const storage = new Storage(client);

export { client, databases, account, avatars, storage, OAuthProvider };
NHero
17 Sep, 2024, 14:16

should i try printing env and see if they arent empty

Kenny
17 Sep, 2024, 14:16

yea

NHero
17 Sep, 2024, 14:17

they are not empty

NHero
17 Sep, 2024, 14:17

env are working fine

Kenny
17 Sep, 2024, 14:21

Can you send your env file and scrub the sensitive data

NHero
17 Sep, 2024, 14:21

ok wait

NHero
17 Sep, 2024, 14:22

APPWRITE_ENDPOINT="https://cloud.appwrite.io/v1" APPWRITE_PROJECT_ID="xxxxxxxxxxxxxx" APPWRITE_API_KEY="bigxxxxxxxxxxxxxxxxxxxxxx"

Kenny
17 Sep, 2024, 14:22

remove the quotes

NHero
17 Sep, 2024, 14:22

from all of them

Kenny
17 Sep, 2024, 14:22

yea

NHero
17 Sep, 2024, 14:23

still the same error

NHero
17 Sep, 2024, 14:23

im using nextJS ,if there is a problem in it

Kenny
17 Sep, 2024, 14:24

Are you doing client side rendering? I believe you'll need to prefix your envs with NEXT_PUBLIC_

Kenny
17 Sep, 2024, 14:24

otherwise they're only available server side.

NHero
17 Sep, 2024, 14:24

ohk

NHero
17 Sep, 2024, 14:25

its working now thanks

Kenny
17 Sep, 2024, 14:26

sweet! If you have anymore issues lmk

Kenny
17 Sep, 2024, 14:26

[SOLVED] Getting an error with google auth

NHero
17 Sep, 2024, 14:32

I have one issue , indexes doesnt get created using node-sdk https://discord.com/channels/564160730845151244/1285159140448145458

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