Back

Ionic Vue - Google Oauth - localhost refused to connect

  • 0
  • Self Hosted
  • Accounts
  • Web
Alsemo
1 Dec, 2023, 10:51

Hi there, I have an issue with Google OAuth login using Ionic / Vue. I tried searching the net for answers but it seems that the information are scarce. Here is my current login code for it:

const loginWithGoogle = () => { try { const response = account.value?.createOAuth2Session( "google", "http://localhost:8100/home", "http://localhost:8100/error" // "http://appwrite.azzotech.com.my/auth/oauth2/success", // "http://appwrite.azzotech.com.my/auth/oauth2/failure" ); return { error: undefined, data: response }; } catch (error) { return { error, data: undefined }; } };

But I always have this "localhost refused to connect" error. I know I'm doing something wrong but I can't pinpoint it. As I was testing on my self-hosting appwrite, I thought that was the issue, so I configure my cloud.appwrite.io to test and it's the same result. So I know something is wrong my login code. Thanks

TL;DR
User is facing an issue with Google OAuth login using Ionic/Vue. They receive a "localhost refused to connect" error. They have provided their current login code. Solution: It seems that the issue might be with the URLs provided in the login code. The user needs to ensure that the URLs are correct and accessible. They may also need to set up deep linking and add a web platform for the domain. Additionally, the user mentions changing the success URL to "http://10.0.2.2:8100/home" in the Android emulator, which resolved the issue for them.
Alsemo
1 Dec, 2023, 11:25

Ionic Vue - Google Oauth - localhost refused to connect

Drake
1 Dec, 2023, 14:39

So your app is running on localhost port 8100?

Alsemo
2 Dec, 2023, 02:44

@Drake When running under web, yes it's using port 8100

Alsemo
2 Dec, 2023, 02:54

@Drake , your question does make me wonder if this is more towards capacitor's port issue. hmm. Let me check on that first. Thanks!

Alsemo
2 Dec, 2023, 03:19

Some improvement, I found that in Android emulator, the app is served in IP: 10.0.2.2:8100 , I changed my success URL to http://10.0.2.2:8100/home and now I received "Error 400: Invalid "success" param: URL host must be one of: localhost, appwrite.azzotech.com.my

Drake
2 Dec, 2023, 05:17

Hmm....you might need to set up deep linking. I'm not sure if that IP address will work when deployed to production.

When you do set up deep linking, you'll probably need to add a web platform for the domain

Alsemo
2 Dec, 2023, 05:47

@Drake Thanks for the pointer. I will check on this

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more