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:
ari melody 2026-01-30 15:55:57 +00:00
parent 45966d40ae
commit 4624c56e54
Signed by: ari
GPG key ID: CF99829C92678188
2 changed files with 30 additions and 16 deletions

View file

@ -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)