Discord Oauth2 support #1858

Closed
opened 2025-11-02 04:15:24 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @l0go on GitHub (Jun 4, 2018).

Read the title!

Originally created by @l0go on GitHub (Jun 4, 2018). Read the title!
GiteaMirror added the type/featuretype/proposal labels 2025-11-02 04:15:24 -06:00
Author
Owner

@chaoticryptidz commented on GitHub (Aug 8, 2018):

I want this so bad.

@chaoticryptidz commented on GitHub (Aug 8, 2018): I want this so bad.
Author
Owner

@sinni800 commented on GitHub (Jan 11, 2019):

Gotta upgrade goth first, then it seems easy to add. The current vendored goth is too old.

@sinni800 commented on GitHub (Jan 11, 2019): Gotta upgrade goth first, then it seems easy to add. The current vendored goth is too old.
Author
Owner

@sinni800 commented on GitHub (Jan 11, 2019):

diff --git a/modules/auth/oauth2/oauth2.go b/modules/auth/oauth2/oauth2.go
index de125c619..ca964b4e7 100644
--- a/modules/auth/oauth2/oauth2.go
+++ b/modules/auth/oauth2/oauth2.go
@@ -16,6 +16,7 @@ import (
        "github.com/markbates/goth"
        "github.com/markbates/goth/gothic"
        "github.com/markbates/goth/providers/bitbucket"
+       "github.com/markbates/goth/providers/discord"
        "github.com/markbates/goth/providers/dropbox"
        "github.com/markbates/goth/providers/facebook"
        "github.com/markbates/goth/providers/github"
@@ -23,7 +24,7 @@ import (
        "github.com/markbates/goth/providers/gplus"
        "github.com/markbates/goth/providers/openidConnect"
        "github.com/markbates/goth/providers/twitter"
-       "github.com/satori/go.uuid"
+       uuid "github.com/satori/go.uuid"
 )

 var (
@@ -124,6 +125,8 @@ func createProvider(providerName, providerType, clientID, clientSecret, openIDCo
        switch providerType {
        case "bitbucket":
                provider = bitbucket.New(clientID, clientSecret, callbackURL, "account")
+       case "discord":
+               provider = discord.New(clientID, clientSecret, callbackURL, "email", "identify")
        case "dropbox":
                provider = dropbox.New(clientID, clientSecret, callbackURL)
        case "facebook":
diff --git a/models/oauth2.go b/models/oauth2.go
index 0640471a4..be575d7c1 100644
--- a/models/oauth2.go
+++ b/models/oauth2.go
@@ -23,6 +23,7 @@ type OAuth2Provider struct {
 // value is used to store display data
 var OAuth2Providers = map[string]OAuth2Provider{
        "bitbucket": {Name: "bitbucket", DisplayName: "Bitbucket", Image: "/img/auth/bitbucket.png"},
+       "discord":   {Name: "discord", DisplayName: "Discord", Image: "/img/auth/discord.png"},
        "dropbox":   {Name: "dropbox", DisplayName: "Dropbox", Image: "/img/auth/dropbox.png"},
        "facebook":  {Name: "facebook", DisplayName: "Facebook", Image: "/img/auth/facebook.png"},
        "github": {Name: "github", DisplayName: "GitHub", Image: "/img/auth/github.png",

Here's a diff that made me able to use discord as the authentication provider.
Gotta add /img/auth/discord.png

@techknowlogick Should I add another issue to update goth?

@sinni800 commented on GitHub (Jan 11, 2019): ``` diff --git a/modules/auth/oauth2/oauth2.go b/modules/auth/oauth2/oauth2.go index de125c619..ca964b4e7 100644 --- a/modules/auth/oauth2/oauth2.go +++ b/modules/auth/oauth2/oauth2.go @@ -16,6 +16,7 @@ import ( "github.com/markbates/goth" "github.com/markbates/goth/gothic" "github.com/markbates/goth/providers/bitbucket" + "github.com/markbates/goth/providers/discord" "github.com/markbates/goth/providers/dropbox" "github.com/markbates/goth/providers/facebook" "github.com/markbates/goth/providers/github" @@ -23,7 +24,7 @@ import ( "github.com/markbates/goth/providers/gplus" "github.com/markbates/goth/providers/openidConnect" "github.com/markbates/goth/providers/twitter" - "github.com/satori/go.uuid" + uuid "github.com/satori/go.uuid" ) var ( @@ -124,6 +125,8 @@ func createProvider(providerName, providerType, clientID, clientSecret, openIDCo switch providerType { case "bitbucket": provider = bitbucket.New(clientID, clientSecret, callbackURL, "account") + case "discord": + provider = discord.New(clientID, clientSecret, callbackURL, "email", "identify") case "dropbox": provider = dropbox.New(clientID, clientSecret, callbackURL) case "facebook": ``` ``` diff --git a/models/oauth2.go b/models/oauth2.go index 0640471a4..be575d7c1 100644 --- a/models/oauth2.go +++ b/models/oauth2.go @@ -23,6 +23,7 @@ type OAuth2Provider struct { // value is used to store display data var OAuth2Providers = map[string]OAuth2Provider{ "bitbucket": {Name: "bitbucket", DisplayName: "Bitbucket", Image: "/img/auth/bitbucket.png"}, + "discord": {Name: "discord", DisplayName: "Discord", Image: "/img/auth/discord.png"}, "dropbox": {Name: "dropbox", DisplayName: "Dropbox", Image: "/img/auth/dropbox.png"}, "facebook": {Name: "facebook", DisplayName: "Facebook", Image: "/img/auth/facebook.png"}, "github": {Name: "github", DisplayName: "GitHub", Image: "/img/auth/github.png", ``` Here's a diff that made me able to use discord as the authentication provider. Gotta add /img/auth/discord.png @techknowlogick Should I add another issue to update goth?
Author
Owner

@techknowlogick commented on GitHub (Jan 11, 2019):

@sinni800 I've just updated Goth in my linked PR, can you try it out?

@techknowlogick commented on GitHub (Jan 11, 2019): @sinni800 I've just updated Goth in my linked PR, can you try it out?
Author
Owner

@sinni800 commented on GitHub (Jan 11, 2019):

Oh I completely oversaw the PR that you made. That changed pretty much the same things so it would work just fine.

@sinni800 commented on GitHub (Jan 11, 2019): Oh I completely oversaw the PR that you made. That changed pretty much the same things so it would work just fine.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#1858