code :
`import { Account, Avatars, Client, Databases, ID, OAuthProvider, Query } from "react-native-appwrite"; import * as Linking from "expo-linking"; import { openAuthSessionAsync } from "expo-web-browser";
const DATABASE_ID = process.env.EXPO_PUBLIC_APPWRITE_DATABASE_ID!; const COLLECTION_ID = process.env.EXPO_PUBLIC_APPWRITE_COLLECTION_ID!; const SAVED_MOVIES_COLLECTION_ID = process.env.EXPO_PUBLIC_APPWRITE_SAVED_MOVIES_COLLECTION_ID!;
const client = new Client() .setEndpoint(process.env.EXPO_PUBLIC_APPWRITE_ENDPOINT!) .setProject(process.env.EXPO_PUBLIC_APPWRITE_PROJECT_ID!)
const avatar = new Avatars(client); const account = new Account(client);
const database = new Databases(client);
export async function login(urlParam:string) { try { const redirectUri = Linking.createURL(urlParam);
const response = await account.createOAuth2Token(
OAuthProvider.Google,
redirectUri
);
if (!response) throw new Error("Create OAuth2 token failed");
console.log("response", response)
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 session");
return true;
} catch (error) { console.log(error); return false; } } `
During Developer It's working Properly Once Create Build And Release Preview APK it's giving below error when we click continue to login button
Error 400
Invalid success param: URL host must be one of: localhost, cloud.appwrite.io, appwrite.io, .appwrite.io,
Type : general_argument_invalid
Recommended threads
- Startup credits or promo code inquiry fo...
Hello Appwrite team, Happy New Year! I hope you’re all doing well. I’m currently exploring backend solutions for a new SaaS project and Appwrite came highly re...
- reset password on expo app
Hi guys, has anyone here implemented the reset password functionality on a expo app? I have a two questions about it. 1. Do I HAVE to have a domain/webpage to...
- OAuth2 Provider is disabled automaticall...
Hi everyone, I'm using self-host Appwrite 1.7.4. I can setup OAuth2 with Google successfully, however the provider is disabled automatically after one day witho...