Skip to content

YouTube

Google OAuth 2.0 with offline access. The auth URL passes access_type=offline and prompt=consent to force refresh-token issuance.

Authentication at a glance

FieldValue
Auth modelOAuth 2.0
Required ENVYOUTUBE_CLIENT_ID, YOUTUBE_CLIENT_SECRET
Callback URL${BASE_URL}/api/v1/auth/youtube/callback
Scopes / permissionshttps://www.googleapis.com/auth/youtube.upload, https://www.googleapis.com/auth/youtube.readonly
Auto token refreshYes — every 7 days before expiry

How to connect

  1. Open ConnectionsYouTubeConnect.
  2. Sign in to Google and grant youtube.upload and youtube.readonly.
  3. Sosyabot creates one channel record per YouTube channel discovered.

Token refresh

Auto-refreshed. Default access-token TTL is 1 hour. The tokenRefresh.queue.ts worker uses the stored refresh_token to mint new access tokens before posts run.

Notes

  • If the OAuth consent returns multiple YouTube channels, Sosyabot creates one Sosyabot channel per YouTube channel. The connect callback iterates youtube.channels.list and saves each.
  • YouTube Data API v3 daily quota is 10000 units by default. Each video upload costs 1600 units — that's ~6 uploads/day on the default quota. Request a quota increase from Google for production volume.
  • The token record stores channelId and channelTitle; thumbnail URLs are cached in data for the connections list UI.

Troubleshooting

If the channel shows needs_reconnect, the access token was rejected by YouTube. Common causes:

  • The user revoked Sosyabot's authorization on the platform.
  • The platform invalidated the token (password change, security event).
  • Your OAuth app credentials rotated and the existing tokens no longer match.

Re-run the connect flow above. See Troubleshooting for the workspace-wide checklist.