Skip to content

Fix OAuth token extraction from httr saved format#160

Merged
soodoku merged 1 commit intogojiplus:masterfrom
TroyHernandez:fix-oauth-token-extraction
Jan 14, 2026
Merged

Fix OAuth token extraction from httr saved format#160
soodoku merged 1 commit intogojiplus:masterfrom
TroyHernandez:fix-oauth-token-extraction

Conversation

@TroyHernandez
Copy link
Copy Markdown
Contributor

Summary

httr's oauth2.0_token saves tokens as a list with a hash key, but yt_oauth was using the list directly instead of extracting the Token2.0 object. This caused "attempt to apply non-function" errors when making API calls with a previously saved token.

The Problem

When a token is saved with saveRDS() and later loaded, httr wraps it in a list structure:

# Token gets saved as:
list("abc123hash" = <Token2.0 object>)

The existing code passed this list wrapper to options(google_token = ...), but API calls expect the actual Token object.

The Fix

Extract token[[1]] when the loaded object is a list wrapper rather than a Token object:

if (is.list(saved_token) && !inherits(saved_token, "Token")) {
  saved_token <- saved_token[[1]]
}

Test Plan

  • Tested with saved OAuth tokens from multiple YouTube channels
  • Verified token refresh works correctly
  • Confirmed upload_video() and other API calls work with loaded tokens

httr's oauth2.0_token saves tokens as a list with a hash key, but
yt_oauth was using the list directly instead of extracting the
Token2.0 object. This caused "attempt to apply non-function" errors
when making API calls with a loaded token.

Now properly extracts token[[1]] when the saved object is a list
wrapper rather than a Token object.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@soodoku soodoku merged commit 99911c2 into gojiplus:master Jan 14, 2026
0 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants