@@ -4,29 +4,37 @@ To run these code samples, you will need to install the dependent libraries via
44the "go get" command. See the client library's getting started guide for more detail:
55https://github.com/google/google-api-go-client/blob/master/GettingStarted.md
66
7- The keyword search and topic search samples can be run via the standard "go run" command
8- once the developerKey constant is populated with an API key created at
9- https://developers.google.com/console .
7+ You also need to enable the YouTube Data API for the project associated with your developer
8+ credentials.
109
11- Example usage:
10+ ## Authorization credentials
11+ To run any sample that does not require user authorization, such as search\_ by\_ keyword.go,
12+ you need to replace the value of the ` developerKey ` constant with a valid API key:
1213
13- go run search\_ by\_ keyword.go
14+ ```
15+ const developerKey = "YOUR DEVELOPER KEY"
16+ ```
1417
15- The YouTube Data API must be enabled for the project associated with this key.
16-
17- To run any sample that requires authorization on behalf of a user, such as checking
18- for uploads, this requires the shared oauth2.go file to be passed as a parameter to "go run".
19- These samples require an OAuth 2.0 client ID and client secret pair, which can
20- also be created at the Google API console at https://developers.google.com/console . After
18+ To run any sample that requires authorization on behalf of a user, such as retrieving the
19+ authenticated user's uploads, you need an OAuth 2.0 client ID and client secret pair. These
20+ can be created at the Google API console at https://developers.google.com/console . After
2121creating your OAuth 2.0 credentials, download the client\_ secret.json file to the directory
2222in which you are running these samples.
2323
24- Example usage:
24+ ## Running samples
25+
26+ Samples can be run with the standard "go run" command as long as your API key or OAuth 2.0
27+ credentials are in place. The samples use the ` errors.go ` file to
28+ print out API errors, so you need to also include that file in the "go run" command. Samples
29+ that require authorization also require the ` oauth2.go ` file to be included in the
30+ "go run" command:
2531
26- go run my \_ uploads.go oauth2.go
32+ Example usages:
2733
28- The ** oauth2.go** file contains code that is shared between the code samples that require
29- OAuth 2.0 authorization, so it must be passed as a parameter to "go run".
34+ ```
35+ go run search\_by\_keyword.go errors.go
36+ go run my\_uploads.go errors.go oauth2.go
37+ ```
3038
3139More information about the YouTube APIs can be found at https://developers.google.com/youtube .
3240
0 commit comments