Click on "New Application" and provide a name for your application.
Fill in all the general information required for your application.
Navigate to the "OAuth2" section and then you will see your "Client ID" and "Client Secret". Make a note of the "Client ID" and "Client Secret". Bear in mind you will only be shown the "Client Secret" once.
Under "OAuth2", go to the "Redirects" section and add the following redirect URI:
# Assuming base path is /api/authhttp://localhost:8080/api/auth/oauth2/discord/callback
For production, replace localhost with the base URL of your GoBetterAuth server (e.g. https://api.yourdomain.com).
import ( "os" "fmt" gobetterauth "github.com/GoBetterAuth/go-better-auth" gobetterauthconfig "github.com/GoBetterAuth/go-better-auth/config" gobetterauthmodels "github.com/GoBetterAuth/go-better-auth/models")config := gobetterauthconfig.NewConfig( // Other config options... gobetterauthconfig.WithSocialProviders( gobetterauthmodels.SocialProvidersConfig{ Default: gobetterauthmodels.DefaultOAuth2ProvidersConfig{ Discord: &gobetterauthmodels.OAuth2Config{ ClientID: os.Getenv("DISCORD_CLIENT_ID"), ClientSecret: os.Getenv("DISCORD_CLIENT_SECRET"), RedirectURL: fmt.Sprintf("%s/auth/oauth2/discord/callback", os.Getenv("GO_BETTER_AUTH_BASE_URL")), }, }, }, ), // Set the trusted origins so that redirects to your webapp are allowed and adds an extra layer of security. gobetterauthconfig.WithTrustedOrigins( gobetterauthmodels.TrustedOriginsConfig{ Origins: []string{"YOUR_FRONTEND_URL e.g. http://localhost:3000"}, }, ),)
In your webapp, create a button when clicked on, it navigates the user to:
# (replace localhost with your GoBetterAuth server URL in production).http://localhost:8080/api/auth/oauth2/discord/login?redirect_to=<YOUR_REDIRECT_URL>
You should be redirected to Discord's authorization page. After authorizing, you will be redirected back to your application.