Skip to content
Back

general_bad_request, code:400, "version": "1.6.1", discord Oauth

  • 1
  • Auth
  • Web
  • Cloud
yash🎧
11 Feb, 2025, 21:22

I am trying to integrate discord Oauth but facing some issue. I already integrated google sign in and it works fine.

TypeScript
  const { loginWithGoogle, loginWithDiscord } = useAuth();

  return (
    <Dialog open={isOpen} onOpenChange={onClose}>
      <DialogContent className="sm:max-w-[400px] flex flex-col gap-6">
        <div className="flex flex-col gap-2 text-center">
          <h2 className="font-bold text-2xl tracking-tight">
            {mode === "signin" ? "Welcome back" : "Create an account"}
          </h2>
          <p className="text-sm text-muted-foreground">
            {mode === "signin"
              ? "Sign in to your account to continue"
              : "Sign up for an account to get started"}
          </p>
        </div>

        <div className="flex flex-col gap-3">
          <Button
            variant="outline"
            onClick={() => loginWithDiscord()}
            className="flex items-center gap-2"
          >
            <DiscordLogoIcon className="w-5 h-5" />
            Continue with Discord
          </Button>

          <Button
            variant="outline"
            onClick={() => loginWithGoogle()}
            className="flex items-center gap-2"
          >
            <FcGoogle className="w-5 h-5" />
            Continue with Google
          </Button>
        </div>
      </DialogContent>
    </Dialog>
  );
}```
// authContext
```const value = {
    user,
    userProfile,
    loading,
    loginWithGoogle: async () => {
      try {
        await loginWithGoogle();
        checkSession();
      } catch (error) {
        console.error("Google login failed:", error);
      }
    },
    loginWithDiscord: async () => {
      try {
        await loginWithDiscord();
        checkSession();
      } catch (error) {
        console.error("Discord login failed:", error);
      }
    },
    logout: async () => {
      try {
        await account.deleteSession("current");
        setUser(null);
      } catch (error) {
        console.error("Logout failed:", error);
      }
    },
  };```

// appwrite.ts
```export const loginWithGoogle = () => {
  return account.createOAuth2Session(
    OAuthProvider.Google,
    "${success_url}",
    "${fail_url}"
  );
};

export const loginWithDiscord = () => {
  console.log("loginWithDiscord");
  return account.createOAuth2Session(
    OAuthProvider.Discord,
    "${success_url}",
    "${fail_url}"
    ["identify", "email"]
  );
};```

when i click on authorize of discord popup, it redirects me to the error:

```{
  "message": "There was an error processing your request. Please check the inputs and try again.",
  "code": 400,
  "type": "general_bad_request",
  "version": "1.6.1"
}```
TL;DR
Developers are facing an issue with integrating Discord OAuth, even though Google sign-in is working fine. The error message "general_bad_request, code: 400" appears with version 1.6.1. Suggestions for resolution include verifying Discord console settings, ensuring requested scopes are enabled, and reviewing the callback URL. Following the tutorial provided should help debug the issue. The error might be related to the callback URL setup.
Nishant
11 Feb, 2025, 23:46

pretty sure it has to do something with the callback URL.

Please follow this tutorial step-by-step: https://appwrite.io/integrations/oauth-discord

double check the discord console settings.

yash🎧
12 Feb, 2025, 06:47

already followed the same. not working. how can I debug further ?

Nishant
12 Feb, 2025, 07:51

can you share the network logs? and also share the google console screenshot, sop that I can verify the URLs!

yash🎧
12 Feb, 2025, 08:35

sent you recording in DM

Nishant
12 Feb, 2025, 10:10

can you just share how your discord settings look like?

just make sure, the scopes that you're requesting are enabled!

yash🎧
12 Feb, 2025, 12:05

it just gives option to copy the generated url and there is no option to save settings . arent we requesting the scope while creating the session ? also if you see the authorize popup, it shows what scopes it is requesting. let me know what should be my next step.

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