Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

enhancement: replace googleplus (deprecated) with google api (#693)

Guilherme Oenningecd32dce08b4
diff --git a/app/pkg/web/oauth.go b/app/pkg/web/oauth.go
index bd1666ace..23cf607f8 100644
--- a/app/pkg/web/oauth.go
+++ b/app/pkg/web/oauth.go
@@ -22,7 +22,6 @@ import (
"golang.org/x/oauth2"
"golang.org/x/oauth2/facebook"
"golang.org/x/oauth2/github"
- "golang.org/x/oauth2/google"
)
func getProviderStatus(key string) int {
@@ -51,16 +50,16 @@ var (
&models.OAuthConfig{
Provider: oauth.GoogleProvider,
DisplayName: "Google",
- ProfileURL: "https://www.googleapis.com/plus/v1/people/me",
+ ProfileURL: "https://www.googleapis.com/oauth2/v2/userinfo",
Status: getProviderStatus(env.Config.OAuth.Google.ClientID),
ClientID: env.Config.OAuth.Google.ClientID,
ClientSecret: env.Config.OAuth.Google.Secret,
Scope: "profile email",
- AuthorizeURL: google.Endpoint.AuthURL,
- TokenURL: google.Endpoint.TokenURL,
+ AuthorizeURL: "https://accounts.google.com/o/oauth2/v2/auth",
+ TokenURL: "https://www.googleapis.com/oauth2/v4/token",
JSONUserIDPath: "id",
- JSONUserNamePath: "displayName",
- JSONUserEmailPath: "emails[0].value",
+ JSONUserNamePath: "name",
+ JSONUserEmailPath: "email",
},
&models.OAuthConfig{
Provider: oauth.GitHubProvider,
diff --git a/app/pkg/web/oauth_test.go b/app/pkg/web/oauth_test.go
index efee9ae01..0905661d7 100644
--- a/app/pkg/web/oauth_test.go
+++ b/app/pkg/web/oauth_test.go
@@ -29,7 +29,7 @@ func TestGetAuthURL_Google(t *testing.T) {
authURL, err := svc.GetAuthURL(oauth.GoogleProvider, "http://example.org", "123")
Expect(err).IsNil()
- Expect(authURL).Equals("https://accounts.google.com/o/oauth2/auth?client_id=GO_CL_ID&redirect_uri=http%3A%2F%2Flogin.test.fider.io%3A3000%2Foauth%2Fgoogle%2Fcallback&response_type=code&scope=profile+email&state=http%3A%2F%2Fexample.org%7C123")
+ Expect(authURL).Equals("https://accounts.google.com/o/oauth2/v2/auth?client_id=GO_CL_ID&redirect_uri=http%3A%2F%2Flogin.test.fider.io%3A3000%2Foauth%2Fgoogle%2Fcallback&response_type=code&scope=profile+email&state=http%3A%2F%2Fexample.org%7C123")
}
func TestGetAuthURL_GitHub(t *testing.T) {