-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
29 lines (24 loc) · 720 Bytes
/
Copy pathconfig.go
File metadata and controls
29 lines (24 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package main
import (
"fmt"
"os"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
)
const defaultGoogleOAuthStateStr string = "5dYo3mAPGIp8OxZepJgs62YKoz0SDjatFhBVgw5JEg7KvucAjh8qkPovuBteJhPF"
func googleOAuthStateStr() string {
ss := os.Getenv(EnvGoogleOAuthStateStr)
if ss == "" {
return defaultGoogleOAuthStateStr
}
return ss
}
func GoogleConfig() *oauth2.Config {
return &oauth2.Config{
ClientID: os.Getenv(EnvGoogleClientID),
ClientSecret: os.Getenv(EnvGoogleClientSecret),
RedirectURL: fmt.Sprintf("%s//%s/callback/google", os.Getenv(EnvProtocol), os.Getenv(EnvHostname)),
Scopes: []string{GoogleOauthScopeEmail, GoogleOauthScopeProfile},
Endpoint: google.Endpoint,
}
}