Accounts

Yt::Account represents a YouTube account. Initialize using either their access or refresh token:

account = Yt::Account.new access_token:  'ya29.ZAF6McAOf0OwU'
account = Yt::Account.new refresh_token: '1/ddxHq4ph-BdR954Xh'
# => All these methods return #<Yt::Account:0x... @id="11668677593">

Authentication

All methods of Yt::Account act on behalf of YouTube accounts (e.g.: upload a video, create a playlist).
To use these methods (marked with   below), you need to get an API Client ID/Secret from Google, obtain an access or refresh token from the account you want to act as, and pass the account as the :auth parameter:

Yt.configuration.client_id = "<your ID>"           ## replace with your client ID
Yt.configuration.client_secret = "<your secret>"   ## replace with your client secret
account = Yt::Account.new refresh_token: "<token>" ## use the account’s refresh token

account.upload_video "http://example.com/remote_video.mp4", title: 'My video'
# => #<Yt::Video …>

A few methods acts on behalf of YouTube content owners (e.g.: fetch the content owner of an account).
To use these methods (marked with   below), you need to get an API Client ID/Secret from Google, obtain an access or refresh token from the content owner, and pass the content owner as the :auth parameter:

Yt.configuration.client_id = "<your ID>"           ## replace with your client ID
Yt.configuration.client_secret = "<your secret>"   ## replace with your client secret
owner = Yt::ContentOwner.new owner_name: "<name>", ## replace with owner’s credentials
                             refresh_token: "<token>"

account = Yt::Account.new id: owner.id, authentication: owner.authentication
account.channel_owners
# => #<Yt::Collections::ChannelOwners …>

List of Yt::Account methods

must authenticate as a YouTube account Account’s User Info
→ Yt docsaccount.id # => "11668677593"
→ Yt docsaccount.email # => "user@example.com"
→ Yt docsaccount.has_verified_email? # => true
→ Yt docsaccount.name # => "Michael Stipe"
→ Yt docsaccount.given_name # => "Michael"
→ Yt docsaccount.family_name # => "Stipe"
→ Yt docsaccount.profile_url # => "https://plus.google.com/11668677593"
→ Yt docsaccount.avatar_url # => "https://lh3.googleusercontent.com/-XCWA/photo.jpg"
→ Yt docsaccount.gender # => "male"
→ Yt docsaccount.locale # => "en"
→ Yt docsaccount.hd # => "example.com"
must authenticate as a YouTube account Account’s Updates
→ Yt docsaccount.upload_video "v.mp4", privacy_status: "private" # => #<Yt::Video …>
→ Yt docsaccount.create_playlist title: "My favorites" # => #<Yt::Playlist …>
→ Yt docsaccount.delete_playlists title: "My favorites" # => [true]
must have content owner privileges Account’s Content Owners
→ Yt docsaccount.owner_name # => "FullScreen"
→ Yt docsaccount.content_owners # => #<Yt::Collections::ContentOwners …>
must authenticate as a YouTube account Account’s Associations
→ Yt docsaccount.channel # => #<Yt::Channel …>
→ Yt docsaccount.playlists # => #<Yt::Collections::Playlists …>
→ Yt docsaccount.related_playlists # => #<Yt::Collections::RelatedPlaylists …>
→ Yt docsaccount.subscribed_channels # => #<Yt::Collections::SubscribedChannels …>
→ Yt docsaccount.videos # => #<Yt::Collections::Videos …>
→ Yt docsaccount.subscribers # => #<Yt::Collections::Subscribers …>