
I get this this error when I try to login with Google on my react native development server app "Error 400
Invalid success
param: URL host must be one of: localhost, cloud.appwrite.io, appwrite.io, *
Type
general_argument_invalid"
The login works fine when I open the app using expo go but not on my development app

Hello! Probably that means you need to add the app into the console platforms. In the overview section, you can go to the bottom of the page and add it.

If not, what's the redirect URL that you have set?

I set it to " * "

In the console?

You need to add the app id like com.example.myapp

Do you mean the Google console ?

Or the Appwrite dashboard?

Appwrite

this my login code export async function login() { try { const redirectUri = Linking.createURL("/"); const redirectUri1 = Linking.createURL("http://localhost:8081/");
const response = await account.createOAuth2Token(
OAuthProvider.Google,
redirectUri,
redirectUri1
);
if (!response) throw new Error("Create OAuth2 token failed");
const browserResult = await openAuthSessionAsync(
response.toString(),
redirectUri
);
if (browserResult.type !== "success")
throw new Error("Create OAuth2 token failed");
const url = new URL(browserResult.url);
const secret = url.searchParams.get("secret")?.toString();
const userId = url.searchParams.get("userId")?.toString();
if (!secret || !userId) throw new Error("Create OAuth2 token failed");
const session = await account.createSession(userId, secret);
if (!session) throw new Error("Failed to create a session");
return true;
} catch (error) {
console.error(error);
return false;
}
}

it's a web based RN

otherwise the redirectUri doesn't make sense in the first place

Oh, that is the URL I get in my terminal when I start an expo server so I thought that will work

Are you using web only?

Nope was using expo go , and the Appwrite google login was working just fine , but when I switched to a development build, I got that error

When I try to log in

Also I'm kinda new to Appwrite and react native 😅

Yo 😭👀

Had the same issue on this thread along with some other quirks you should be aware of, at least if you are using Android to test:
https://discord.com/channels/564160730845151244/1320926689387089930

heyyy thank you for this was able to fix it kinda but i got this after i log in , this is my login code export async function login() { try {
const redirectUri = new URL(Linking.createURL('/',{isTripleSlashed:false}));
if(!redirectUri.hostname){
redirectUri.hostname='localhost'
}
// const redirectUri1 = Linking.createURL("http://localhost:8081/");
const response = await account.createOAuth2Token(
OAuthProvider.Google,
redirectUri.toString(),
// redirectUri1
);
console.log(redirectUri)
if (!response) throw new Error("Create OAuth2 token failed");
const browserResult = await WebBrowser.openAuthSessionAsync(
response.href.toString(),
redirectUri.toString(),
);
if (browserResult.type !== "success")
throw new Error("Create OAuth2 token failed");
const url = new URL(browserResult.url);
const secret = url.searchParams.get("secret")?.toString();
const userId = url.searchParams.get("userId")?.toString();
if (!secret || !userId) throw new Error("Create OAuth2 token failed");
const session = await account.createSession(userId, secret);
if (!session) throw new Error("Failed to create a session");
return true;
} catch (error) {
console.error(error);
return false;
}
}

Didn't really understand what you guys did after to fix that 🤲
Recommended threads
- Google login error: {"message":"Invalid ...
hi, im trying to use google login with account.createOAuth2Session( 'google', 'profevardilla.pages.dev', 'profevardilla.pages.dev'...
- Create owner team member with Server fun...
I understand that when creating a team with a function, the user that made the request will not be the owner so I think I have to add the user that did the requ...
- Check User on Server SDK
I have my backend which exposes some endpoints let's say /feed (return a hard coded json as response) I want this to be only accessible to users who are curre...
