#Cant Sign in with Google

83 messages · Page 1 of 1 (latest)

quaint basalt
#

I am making a react native expo app and am trying to implement logging into the app using google OAuth, i get an error and it want me to register my new client as a platform, i have tried making a react native platform but cant ping it since i dont know how to ping the appwrite project from an already existing app (my expo app is in development mode).

I'm pretty new to using appwrite and I was using it when i had to type a command into my console to link the project, but that changed recently i think and now i dont know how im supposed to do so. For clarity i can do everything else appwrite provides but not OAuth

quaint basalt
#

i tried using the code provided in the documentation, but now I have this error, i tried installng expo-crypto but it didnt solve the issue

ivory vault
#

Here is a working example

quaint basalt
#

I used the docs and it works but when choosing the google account the browser doesnt redirect me back to the app and instead is stuck in a infinite load, the user account is created in the appwrite console auth tab, but i cant get this line to return me a value: const result = await WebBrowser.openAuthSessionAsync(${loginUrl}, scheme);

ivory vault
quaint basalt
#

Do you mean the code or the value?

#

if its the code, this is it:
async function handleSignInGoogle() {
try {
const deepLink = new URL(makeRedirectUri({ preferLocalhost: true }));
const scheme = ${deepLink.protocol}//; // e.g. 'exp://' or 'appwrite-callback-<PROJECT_ID>://'

    // Start OAuth flow
    const loginUrl = await account.createOAuth2Token(
        OAuthProvider.Google,
        `${deepLink}`,
        `${deepLink}`,
    );

    // Open loginUrl and listen for the scheme redirect
    const result = await WebBrowser.openAuthSessionAsync(`${loginUrl}`, scheme);

    // Extract credentials from OAuth redirect URL
    const url = new URL(result.url);
    const secret = url.searchParams.get('secret');
    const userId = url.searchParams.get('userId');

    // Create session with OAuth credentials
    await account.createSession(userId, secret);


    return true;
} catch (error) {
    console.error(error);
    return false;
}

}

#

on an emulator the browser doesnt even load the page

mint badger
ivory vault
quaint basalt
quaint basalt
#

yeah

ivory vault
#

Expo should not be outputting this value

#

Are you sure this is the console log of the scheme?

quaint basalt
#

its both the scheme and the deeplink

ivory vault
#

Expo go should be outputting exp://.....

quaint basalt
#

the documentatin says i have to change the scheme in app.json to appwrite-callback-<PROJECT_ID>

ivory vault
quaint basalt
#

oh, maybe the problem is that my app is in development mode

ivory vault
#

Can you show a ss of app.json? Or provide the file?

#

Although everything looks ok

quaint basalt
ivory vault
#

Can you run the simulation on expo go instead of development mode?
I cannot just pin point what is going wrong and try to recreate this.

quaint basalt
#

i am guessing that the problem is the fact that im using a development build that doesnt use the exp:// scheme so the browser doesnt know where to redirect me, but i cant go back to using expo go because i am using expo maps, and i need to use native modules

ivory vault
#

In your app json can you try
["scheme"]?

ivory vault
quaint basalt
#

the browser doesnt see this as an address and just searches it as a text

ivory vault
#

Did you change the scheme after you started/build the app?

quaint basalt
#

yes, but i rebuilt the app after

ivory vault
#

is the dev build done with eas cli?
If yes can You share the app download link?
So that i can do some checks?

quaint basalt
ivory vault
#

I think there is a problem with built
appwrite-callback-68932cf00020cd859be4://
This is not opeing the app even though the scheme is set.
I decompiled and checked every thing was ok

quaint basalt
#

do you have any idea how i could fix this?

#

would it help to build the app agian?

ivory vault
quaint basalt
#

i would if i knew how lol

ivory vault
quaint basalt
#

yeah

ivory vault
#

I will set up a demo app in my device to check for things.
Could you wait a bit for that? 🙂
I am currently outside.
You could develop other features meanwhile
Btw
You could try react native maps
Works on expo go instead of making a build

quaint basalt
#

Build concurrency limit reached for your account. Build will enter queue once a concurrency becomes available.
Aight ill have to wait an hour i think

quaint basalt
quaint basalt
#

ill send the link to download the preview when its done building 🙂

ivory vault
quaint basalt
#

so if i build the app again it could fix the issue?

ivory vault
quaint basalt
#

ok i will try it

quaint basalt
#

sadly building the app again didnt fix the problem

#

the browser still doesnt want to redirect me to the app

quaint basalt
# ivory vault Should fix it

i think i found the problem, but i dont know how to fix it, i think that the metro bundler doenst use the scheme i set in app.json, because i says: › Metro waiting on exp+proiectlicenta://expo-development-client/?url=http%3A%2F%2F192.168.100.28%3A8081

ivory vault
#

I dont know if this is relevant or not
In my first development expo asked the scheme shoul be an array
["scheme"]
You can try this.

quaint basalt
#

you mean in app.json?

ivory vault
#

And instead of using up all your build quota via eas
You could try running on android studio

quaint basalt
#

can you please send me an example cause i dont undersand what you mean by having scheme as an array?

ivory vault
#

Ok

quaint basalt
ivory vault
quaint basalt
ivory vault
#

Ok
Can I try to clone your repo and test everything if needed?
You can check the PR and apply it directly without having me as a contributor
So that it does not effect your licence?

quaint basalt
#

i hope that it will just work, it wont effect my license in any way, i am just ultra happy to have someone that at least tries to help me 🙂

ivory vault
#

Ok. Will get on it

quaint basalt
#

thank you a lot

ivory vault
#

hey
@quaint basalt current branch works
So I did not modified anything
I think You know what this means 😁

#

the problem might have been how scheme was declared

quaint basalt
#

you can sign in with google?

ivory vault
#

yep

#

I am inside

quaint basalt
#

bruh, then why cant i do it😭

ivory vault
#

did you made a build after modifying the app.json?

quaint basalt
#

ill try it again tommorow, sadly i gotta log off, thank you so much for the help today

ivory vault
#

sent you a dm

#

the apk sent should work
I will try to create another debug apk via eas cli