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
- Database column name change makes table ...
Hi, new here! I'm currently building an app where there's a table called "track_sessions" whose column "creator" I wanted to change to "creatorID". However, af...
- How to handle ghost accounts created by ...
Appwrite create the account with the email and send an invitation link with a secret. I am able to accept the invitation and add the account as a member on the ...
- SyntaxError: The requested module 'node-...
I am trying to use appwrite functions and in the function i am creating rows but i got this error when i executed the funtion. As i checked docs there TablesDB...