appwrite / sdk-for-react-native

[READ ONLY] Official Appwrite React Native SDK 💙 ⚛︎
https://appwrite.io
BSD 3-Clause "New" or "Revised" License
3.74k stars 21 forks source link

Cant OAuth2 when on testflight #34

Open schoolofai opened 1 month ago

schoolofai commented 1 month ago

hi i am having issues with using google oauth for login - I am using react native sdk - it all works when on expo go , but when i installed it to testfight it stops working - and when trying to login with google - in get invalid sucess param should be one of - localhost .... etc . here is my sign in code -

    let redirectUri = makeRedirectUri({ preferLocalhost: true });
    console.log("Redirect URI:", redirectUri);

    const url = await account.createOAuth2Token(
      "google",
      redirectUri,
      redirectUri,
      [
        "profile",
        "email",
        "https://www.googleapis.com/auth/youtube",
        "https://www.googleapis.com/auth/youtube.force-ssl",
        "https://www.googleapis.com/auth/youtube.upload",
        "https://www.googleapis.com/auth/youtubepartner",
      ]
    );
    console.log("URL:", url);
    if (!url) {
      throw new Error("Failed to create OAuth2 session");
    }

    const result = await openAuthSessionAsync(url.href, redirectUri);
    console.log("Auth session result:", result);

    if (result.type === "success") {
      if ("url" in result) {
        const resultUrl = new URL(result.url);
        const secret = resultUrl.searchParams.get("secret");
        const userId = resultUrl.searchParams.get("userId");
        if (!secret || !userId) return;
        await account.createSession(userId, secret);
        const user = await account.get().catch((e) => {
          console.warn(e);
          return null;
        });
        console.log("user:", user);

see the screen shot for google cloud credentials ImageImage

stnguyen90 commented 3 weeks ago

@schoolofai, thanks for creating this issue! 🙏🏼 Could you please share exactly what the redirectUri is when running via TestFlight? It's likely the hostname in the URL hasn't been registered in your Appwrite project yet.