Table of Contents

Class NodeYouTube

Namespace
Nyra
Assembly
Nyra.dll

The YouTube source configuration of a node.

public sealed class NodeYouTube
Inheritance
NodeYouTube
Inherited Members

Methods

GetConfigAsync(bool, CancellationToken)

Reads the runtime YouTube configuration of the node, the masked refresh token and visitor data, whether a token is configured at all.

public Task<YouTubeConfig> GetConfigAsync(bool validate = false, CancellationToken cancellationToken = default)

Parameters

validate bool

Whether the server should validate the stored token while reading.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<YouTubeConfig>

The current YouTube configuration, tokens masked.

Remarks

With validate the server also probes whether the stored token still works.

Exceptions

NotSupportedException

The node is not NodeLink.

IncompatibleServerException

The server's /v4/info version is not supported.

RefreshTokenAsync(string, CancellationToken)

Exchanges a YouTube refresh token for a fresh access token through the node's OAuth route.

public Task<YouTubeToken> RefreshTokenAsync(string refreshToken, CancellationToken cancellationToken = default)

Parameters

refreshToken string

The refresh token to exchange.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<YouTubeToken>

The issued access token.

Remarks

The request carries the server's own OAuth credentials, the client only supplies the refresh token.

Exceptions

ArgumentException

refreshToken is null or blank.

RestException

The token exchange failed.

NotSupportedException

The node is not NodeLink.

IncompatibleServerException

The server's /v4/info version is not supported.

UpdateConfigAsync(string?, string?, CancellationToken)

Changes the runtime YouTube configuration of the node.

public Task<YouTubeConfigUpdate> UpdateConfigAsync(string? refreshToken = null, string? visitorData = null, CancellationToken cancellationToken = default)

Parameters

refreshToken string

The new OAuth refresh token, null keeps the current one.

visitorData string

The new visitor data, null keeps the current one.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<YouTubeConfigUpdate>

The outcome of the update as the server reports it.

Remarks

The server validates a new refresh token before applying it and rejects the whole patch when it fails, so a bad token never breaks the working configuration.

Exceptions

ArgumentException

Both refreshToken and visitorData are null or empty.

RestException

The server rejected the new token, no changes were applied.

NotSupportedException

The node is not NodeLink.

IncompatibleServerException

The server's /v4/info version is not supported.