From bc137f6106849818eed1521da896d91a894f312d Mon Sep 17 00:00:00 2001 From: Josh Michielsen Date: Fri, 17 May 2019 02:33:25 +0100 Subject: [PATCH] Add API key option for use in CI (#14) * Add API key option for use in CI * Enable test job in CI * Build requires test * Disable lint --- .circleci/config.yml | 10 +++++----- providers/youtube.go | 7 +++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3df484f..8a4df7a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -58,8 +58,8 @@ jobs: workflows: lint_and_build: jobs: - - lint - # - test - - build - # requires: - # - test \ No newline at end of file + # - lint + - test + - build: + requires: + - test diff --git a/providers/youtube.go b/providers/youtube.go index 434ac69..ace0d74 100644 --- a/providers/youtube.go +++ b/providers/youtube.go @@ -22,6 +22,7 @@ import ( "golang.org/x/oauth2/google" "gopkg.in/yaml.v2" + "google.golang.org/api/googleapi/transport" "google.golang.org/api/youtube/v3" ) @@ -302,6 +303,12 @@ https://developers.google.com/api-client-library/python/guide/aaa_client_secrets // getClient uses a Context and Config to retrieve a Token // then generate a Client. It returns the generated Client. func getClient(scope string) *http.Client { + if apiKey := os.Getenv("YOUTUBE_API"); apiKey != "" { + return &http.Client{ + Transport: &transport.APIKey{Key: apiKey}, + } + } + ctx := context.Background() b := []byte(accessJSON)