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
- SMS OTP not delivered to Australian (+61...
Hey team! I'm having an issue with SMS OTP delivery to Australian phone numbers in my Appwrite Cloud project. What's happening: account.createPhoneToken() co...
- OAuth provider credentials reverting [CR...
Hi team, I’m experiencing repeated OAuth configuration resets in my Appwrite project. ## Issue 1 – Google OAuth credentials reverting * I configure my own Goog...
- updateSession isn't working for google o...
I'm building an app using react native with expo. An image of my code is attached. The code is a useEffect that i have in a context that wraps the root layout ...