refactor credentials files

This commit is contained in:
DBras 2025-03-01 19:19:21 +01:00
parent 37f3011630
commit 2ec27d11ab
3 changed files with 5 additions and 2 deletions

View File

@ -14,8 +14,11 @@ import (
"google.golang.org/api/option" "google.golang.org/api/option"
) )
const TOKEN_FILE string = "creds/token.json"
const CREDENTIALS_FILE string = "creds/credentials.json"
func getClient(config *oauth2.Config) *http.Client { func getClient(config *oauth2.Config) *http.Client {
token_file := "token.json" token_file := TOKEN_FILE
token, err := tokenFromFile(token_file) token, err := tokenFromFile(token_file)
if err != nil { if err != nil {
token = getTokenFromWeb(config) token = getTokenFromWeb(config)
@ -64,7 +67,7 @@ func saveToken(path string, token *oauth2.Token) {
func main() { func main() {
ctx := context.Background() ctx := context.Background()
creds_b, err := os.ReadFile("credentials.json") creds_b, err := os.ReadFile(CREDENTIALS_FILE)
if err != nil { if err != nil {
log.Fatalf("Unable to read client secret file: %v", err) log.Fatalf("Unable to read client secret file: %v", err)
} }