refactor credentials files
This commit is contained in:
parent
37f3011630
commit
2ec27d11ab
7
main.go
7
main.go
|
|
@ -14,8 +14,11 @@ import (
|
|||
"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 {
|
||||
token_file := "token.json"
|
||||
token_file := TOKEN_FILE
|
||||
token, err := tokenFromFile(token_file)
|
||||
if err != nil {
|
||||
token = getTokenFromWeb(config)
|
||||
|
|
@ -64,7 +67,7 @@ func saveToken(path string, token *oauth2.Token) {
|
|||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
creds_b, err := os.ReadFile("credentials.json")
|
||||
creds_b, err := os.ReadFile(CREDENTIALS_FILE)
|
||||
if err != nil {
|
||||
log.Fatalf("Unable to read client secret file: %v", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue