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
- Oauth issue
Hi, can anyone help me in the Oauth issue, Its working fine in dev but its showing Invalid redirect during production. I have check the redirect url and all. St...
- Google/Apple OAuth to show continue to "...
hi everyone, I am building a react-native app with expo and appwrite. I have setup an OAuth flow with Google and Apple following this doc (https://appwrite.io/b...
- getFileViewURL isnt working on android
i trid the adding the jwt token to the end of the url still nothing. but it works fine on ios https://fra.cloud.appwrite.io/v1/storage/buckets/693a0xxxxxxxxf2d...