update recipe modal
This commit is contained in:
parent
ac45ca47d5
commit
2328da0ce8
11 changed files with 238 additions and 40 deletions
|
|
@ -4,8 +4,9 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"os"
|
||||
"log"
|
||||
"recipe-manager/config"
|
||||
"recipe-manager/helpers"
|
||||
"recipe-manager/models"
|
||||
|
||||
"golang.org/x/oauth2"
|
||||
|
|
@ -28,28 +29,18 @@ type oauthService struct {
|
|||
|
||||
func NewOAuthService(cfg *config.ServerConfig) OAuthService {
|
||||
|
||||
file, err := os.Open("client_secret.json")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer file.Close()
|
||||
clientSecret, err := helpers.GetClientSecret("client_secret.json")
|
||||
|
||||
var clientSecret map[string]interface{}
|
||||
json.NewDecoder(file).Decode(&clientSecret)
|
||||
if err != nil {
|
||||
log.Fatalf("Unable to get client secret: %v", err)
|
||||
}
|
||||
|
||||
clientSecret.RedirectURL = cfg.ServerDomain + "/auth/google/callback"
|
||||
|
||||
return &oauthService{
|
||||
cfg: cfg,
|
||||
gConfig: &oauth2.Config{
|
||||
ClientID: clientSecret["web"].(map[string]interface{})["client_id"].(string),
|
||||
ClientSecret: clientSecret["web"].(map[string]interface{})["client_secret"].(string),
|
||||
RedirectURL: cfg.ServerDomain + "/auth/google/callback",
|
||||
Scopes: []string{"https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile"},
|
||||
Endpoint: oauth2.Endpoint{
|
||||
AuthURL: clientSecret["web"].(map[string]interface{})["auth_uri"].(string),
|
||||
TokenURL: clientSecret["web"].(map[string]interface{})["token_uri"].(string),
|
||||
},
|
||||
},
|
||||
nonce: make(map[string]map[string]string),
|
||||
cfg: cfg,
|
||||
gConfig: clientSecret,
|
||||
nonce: make(map[string]map[string]string),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue