class

Yt::YouTubeOAuthClient

Inherits Reference < Object

Client for handling YouTube OAuth 2.0 authentication flow.

This client manages the OAuth2 authorization process for accessing YouTube APIs, including generating authorization URLs, exchanging authorization codes for tokens, and refreshing expired tokens.

Example

client = YouTubeOAuthClient.new("client_id", "client_secret", "http://localhost:8080")
auth_url = client.get_authorize_uri("https://www.googleapis.com/auth/youtube")
token = client.get_access_token("authorization_code")

Constants

AUTH_URI = "https://accounts.google.com/o/oauth2/auth"
DEFAULT_SCOPE = "https://www.googleapis.com/auth/youtube"
TOKEN_URI = "https://oauth2.googleapis.com/token"

Constructors

new(client_id : String, client_secret : String = "", redirect_uri : String = "http://localhost:1234")
Source

Instance methods

get_access_token(authorization_code : String) : OAuth2::AccessToken

Exchange authorization code for access and refresh tokens

authorization_code - The authorization code received from OAuth flow Returns OAuth2::AccessToken containing access_token and refresh_token Raises ValidationError if authorization_code is invalid Raises NetworkError on network failures Raises AuthenticationError if code is invalid or expired

Source
get_authorize_uri(scope : String = DEFAULT_SCOPE) : String

Generate an OAuth2 authorization URL for the specified scope

scope - The OAuth2 scope string defining API access permissions Returns a String containing the authorization URL Raises ValidationError if scope is invalid

Source
refresh_access_token(refresh_token : String) : OAuth2::AccessToken

Refresh an expired access token using the refresh token

refresh_token - The refresh token obtained during initial authorization Returns OAuth2::AccessToken::Bearer with new access token Raises ValidationError if refresh_token is invalid Raises NetworkError on network failures Raises AuthenticationError if the refresh token is invalid or revoked

Source