Hello everyone i am trying to login with ios and android in react native - expo but it is not successful. And this is the code which i am using to login
app.json: { "expo": { "scheme": "doko" } }
import { Client, Account, OAuthProvider } from "appwrite"; import { makeRedirectUri } from 'expo-auth-session' import * as WebBrowser from 'expo-web-browser';
const appwriteClient = new Client() .setEndpoint('https://app.doko.so/v1') .setProject('682f5edd0032dee5da20') .setPlatform('com.dokocorp.doko');
const appwriteAccount = new Account(appwriteClient);
const signInWithIos = async () => { try { console.log("appwriteAccount", appwriteAccount);
// Custom redirect scheme
const redirectUri ="https://doko";
// Tạo deep link với expo-auth-session
const deepLink = new URL(makeRedirectUri({}));
console.log("deepLink", deepLink);
const scheme = `${deepLink.protocol}`;
console.log("scheme", scheme);
// Tạo OAuth2 token URL từ Appwrite
const loginUrl = await appwriteAccount.createOAuth2Token(
OAuthProvider.Apple,
`${deepLink}/success`,
`${deepLink}`,
);
console.log("loginUrl", loginUrl);
// Mở WebBrowser cho login
const result = await WebBrowser.openAuthSessionAsync(
`${loginUrl}`,
scheme
);
console.log("result", result);
if (result.type === "success" && result.url) {
const url = new URL(result.url);
const secret = url.searchParams.get("secret");
const userId = url.searchParams.get("userId");
if (secret && userId) {
// Tạo session
await appwriteAccount.createSession(userId, secret);
Alert.alert("✅ Login success!");
} else {
Alert.alert("🚨 OAuth failed", "Cannot get secret/userId");
}
} else {
Alert.alert("❌ Login fail");
}
} catch (err: any) { console.error(err); Alert.alert("⚠️ Error", err.message || "Something went wrong"); } };
I have configured all the files, I followed the doc, but when calling WebBrowser.openAuthSessionAsync, it does not use the deepLink created from the code
Recommended threads
- {"code": 1008, "message": "Invalid Origi...
Nothing has changed in my application or console settings so I'm curious as to what I need to do to fix this. I already have the client registered so I'm not en...
- TSL Certificate Issues
Hi Appwrite Discord Community, I got a problem with my Self-Hosted instance. I only want, that I can use my programm with the Appwrite Backend without .selfSig...
- React Native/iOS platform integrations h...
Anyone else have this issue where platform identifiers have been lost/wiped and no option/field available to update them in the console?