fix oauth2 storage and reuse
pretty sure this isn't the *best* approach, but it's an approach that works.
This commit is contained in:
parent
45966d40ae
commit
4624c56e54
2 changed files with 30 additions and 16 deletions
|
|
@ -168,7 +168,11 @@ func BuildDescription(video *Video) (string, error) {
|
|||
return strings.TrimSpace(out.String()), err
|
||||
}
|
||||
|
||||
func UploadVideo(ctx context.Context, token *oauth2.Token, video *Video) (*youtube.Video, error) {
|
||||
func UploadVideo(
|
||||
ctx context.Context,
|
||||
tokenSource oauth2.TokenSource,
|
||||
video *Video,
|
||||
) (*youtube.Video, error) {
|
||||
title, err := BuildTitle(video)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to build title: %v", err)
|
||||
|
|
@ -181,7 +185,7 @@ func UploadVideo(ctx context.Context, token *oauth2.Token, video *Video) (*youtu
|
|||
service, err := youtube.NewService(
|
||||
ctx,
|
||||
option.WithScopes(youtube.YoutubeUploadScope),
|
||||
option.WithTokenSource(oauth2.StaticTokenSource(token)),
|
||||
option.WithTokenSource(tokenSource),
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create youtube service: %v\n", err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue