Skip to content

Commit

Permalink
added
Browse files Browse the repository at this point in the history
  • Loading branch information
allan committed Jul 8, 2024
1 parent cab0143 commit a9a4ca6
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ import (

"github.com/HiWay-Media/youtube-go-example/env"
"golang.org/x/oauth2"
"google.golang.org/api/option"
"google.golang.org/api/youtube/v3"
)

func main() {

config := env.GetEnvConfig()
appConfig := env.GetEnvConfig()
ctx := context.Background()
conf := &oauth2.Config{
ClientID: config.ClientID, // from https://console.developers.google.com/project/<your-project-id>/apiui/credential
ClientSecret: config.ClientSecret, // from https://console.developers.google.com/project/<your-project-id>/apiui/credential
ClientID: appConfig.ClientID, // from https://console.developers.google.com/project/<your-project-id>/apiui/credential
ClientSecret: appConfig.ClientSecret, // from https://console.developers.google.com/project/<your-project-id>/apiui/credential
Endpoint: oauth2.Endpoint{
AuthURL: "https://provider.com/o/oauth2/auth",
TokenURL: "https://provider.com/o/oauth2/token",
Expand Down Expand Up @@ -46,10 +47,11 @@ func main() {
log.Fatal(err)
}

client := conf.Client(ctx, tok)
client.Get("...")
//client := conf.Client(ctx, tok)
//client.Get("...")

service, err := youtube.NewService(ctx)
// Create a new YouTube service
service, err := youtube.NewService(ctx, option.WithTokenSource(conf.TokenSource(ctx, tok)))
if err != nil {
log.Fatalf("Unable to create YouTube service: %v", err)
}
Expand All @@ -66,5 +68,6 @@ func main() {
// The API returns a 400 Bad Request response if tags is an empty string.
upload.Snippet.Tags = []string{"test", "upload", "api"}
log.Println("Uploading video...", service)
//call := service.Videos.Insert([]string{"snippet", "status"}, upload)
call := service.Videos.Insert([]string{"snippet", "status"}, upload)
log.Println("Uploading video...", call)
}

0 comments on commit a9a4ca6

Please sign in to comment.