Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discord Oauth2 support #4125

Closed
l0go opened this issue Jun 4, 2018 · 5 comments · Fixed by #4476
Closed

Discord Oauth2 support #4125

l0go opened this issue Jun 4, 2018 · 5 comments · Fixed by #4476
Labels
type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/proposal The new feature has not been accepted yet but needs to be discussed first.
Milestone

Comments

@l0go
Copy link

l0go commented Jun 4, 2018

Read the title!

@techknowlogick techknowlogick added type/proposal The new feature has not been accepted yet but needs to be discussed first. type/feature Completely new functionality. Can only be merged if feature freeze is not active. labels Jun 4, 2018
@lafriks lafriks added this to the 1.6.0 milestone Jun 4, 2018
@chaoticryptidz
Copy link

I want this so bad.

@lunny lunny modified the milestones: 1.6.0, 1.x.x Aug 9, 2018
@techknowlogick techknowlogick modified the milestones: 1.6.0, 1.7.0 Aug 29, 2018
@techknowlogick techknowlogick modified the milestones: 1.7.0, 1.8.0 Dec 19, 2018
@sinni800
Copy link

sinni800 commented Jan 11, 2019

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

@sinni800
Copy link

sinni800 commented 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?

@techknowlogick
Copy link
Member

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

@sinni800
Copy link

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

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants