Back

[SOLVED] github oauth error "general_argument_invalid"

  • 0
  • Web
Eddie Jaoude | EddieHub
20 Nov, 2023, 19:24

I get the error with NextJS and GitHub OAuth, i found this and tried to use it to solve by moving from locahost to using sub domains https://github.com/appwrite/appwrite/issues/1203#issuecomment-850787160

TypeScript
{"message":"Invalid `success` param: URL host must be one of: localhost, appwrite.jaoudestudios.co.uk, *.vercel.app,localhost,rating.jaoudestudios.co.uk","code":400,"type":"general_argument_invalid","version":"0.11.33"}

After research, I have done the following, am I missing something?

  • used a custom sub domain appwrite.jaoudestudios.co.uk and added it to my Appwrite Cloud project
  • using custom sub domain to connect to Appwrite
TypeScript
const client = new Client()
  .setEndpoint("https://appwrite.jaoudestudios.co.uk/v1")
  .setProject(process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID);
  • using a host file for rating.jaoudestudios.co.uk to point to localhost, and added to allowed hostnames
TypeScript
const login = async () => {
    account.createOAuth2Session(
      "github",
      "http://rating.jaoudestudios.co.uk:3000/account",
      "http://rating.jaoudestudios.co.uk:3000/failed"
    );
  };
  • github oauth settings is https://appwrite.jaoudestudios.co.uk/v1/account/sessions/oauth2/callback/github/XXX
TL;DR
The user was experiencing an error with GitHub OAuth, specifically "general_argument_invalid". They were able to solve the issue by using a custom subdomain for Appwrite and adding it to their project. They also used a host file to point their desired subdomain to localhost and added it to the allowed hostnames. The problem was resolved by making these changes.
Drake
20 Nov, 2023, 19:41

For the hostname, can you try creating separate web platforms for each?

Eddie Jaoude | EddieHub
20 Nov, 2023, 19:43

I only created the sub domains because of the GitHub Discussion with cross domain limitations on OAuth, I am happy to use localhost

Drake
20 Nov, 2023, 19:43

In order for the cookies to work as 1st party, the Appwrite endpoint needs to be a subdomain for your app. So if your app is on rating.jaoudestudios.co.uk, the Appwrite endpoint would need to be on something like appwrite.rating.jaoudestudios.co.uk

Eddie Jaoude | EddieHub
20 Nov, 2023, 19:44

oh really? not what I understand from the github discussion but I can try still that

Drake
20 Nov, 2023, 19:44

You can try...

Eddie Jaoude | EddieHub
20 Nov, 2023, 19:44

I will try now πŸ‘

Drake
20 Nov, 2023, 19:45

But you'll need separate web platforms. Comma separated values here won't work

Eddie Jaoude | EddieHub
20 Nov, 2023, 19:45

ok, so I will need one for each sub domain?

Eddie Jaoude | EddieHub
20 Nov, 2023, 19:49

it seems to work, but I made 2 changes, I think the fix was removing the comma separate domains and leaving only 1

Eddie Jaoude | EddieHub
20 Nov, 2023, 19:50

thank you for your help Steven!

Drake
20 Nov, 2023, 19:50

Fyi, I'm pretty sure we have a PR pending merge/release to return an error if you pass in invalid hostname

Eddie Jaoude | EddieHub
20 Nov, 2023, 19:51

it has multiple domains in there already to begin with, so I just appended an additional domain - that would be great, it would have saved me most of the day

Drake
20 Nov, 2023, 19:51

Hmm I'm not sure how/why it had multiple 🧐

D5
20 Nov, 2023, 19:55

[SOLVED] github oauth error "general_argument_invalid"

D5
20 Nov, 2023, 20:21

github oauth error "general_argument_invalid"

D5
20 Nov, 2023, 20:21

@Eddie Jaoude | EddieHub Sorry, I closed the wrong post 🫣

D5
20 Nov, 2023, 20:21

I thought this was the old one

D5
20 Nov, 2023, 20:22

My apologies πŸ™

Eddie Jaoude | EddieHub
20 Nov, 2023, 20:22

no worries πŸ™‚

D5
20 Nov, 2023, 20:23

Anyways, did you have solved it?

Eddie Jaoude | EddieHub
20 Nov, 2023, 20:24

yes it is now solved πŸ‘

D5
20 Nov, 2023, 20:27

Okay, so seems I could mark it anyways πŸ˜…

D5
20 Nov, 2023, 20:27

Glad to hear

D5
20 Nov, 2023, 20:28

[SOLVED] github oauth error "general_argument_invalid"

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