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
- User ID case sensitivity
I see that through REST (and SDK as well), getting a user is not case sensitive. And even though documentation does not clearly state that it is, the wording "V...
- Weird permission failure
when creating an account I use following methods: ``` Future<void> register(String email, String password, String username) async { final user = await accoun...
- Flutter Android oAuth is no more working
I currently don't get the oAuth login to work in flutter android. it works on ios and on web. but when try to use it on Android, i get to the point where the ca...