YouTubeSessionGenerator 1.0.1

dotnet add package YouTubeSessionGenerator --version 1.0.1
                    
NuGet\Install-Package YouTubeSessionGenerator -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="YouTubeSessionGenerator" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="YouTubeSessionGenerator" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="YouTubeSessionGenerator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add YouTubeSessionGenerator --version 1.0.1
                    
#r "nuget: YouTubeSessionGenerator, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=YouTubeSessionGenerator&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=YouTubeSessionGenerator&version=1.0.1
                    
Install as a Cake Tool

YouTubeSessionGenerator

YouTubeSessionGenerator is a .NET library which allows you to generate valid trusted sessions for the internal YouTube API (InnerTube) including Visitor Data, Proof of Origin Tokens (PoTokens) & Rollout Tokens. Some of these parameters may be required to access certain parts of the InnerTube API.

This library is especially useful for services, automation tools, or projects that require valid authentication for YouTube communication - without the overhead of a full browser environment.


Features

  • Trusted Sessions: Generate sessions that pass YouTube�s anti-bot checks - unlock access to protected endpoints
  • Easy to Use: Just a few lines of code required - no need to worry about the low-level details
  • Configurable: Built for .NET with flexible config & pluggable JS environment support - no browser needed

Getting Started

using YouTubeSessionGenerator;
using YouTubeSessionGenerator.Js.Environments;

using NodeEnvironment myCustomJsEnvironment = new(); // Make sure this gets dispoed!

YouTubeSessionConfig config = new()
{
    JsEnvironment = myCustomJsEnvironment,  // Required when generating Proof of Origin Tokens
    HttpClient = myCustomHttpClient,        // Optional: Provide your own HttpClient
    Logger = myCustomLogger                 // Optional: Enable logging
};
YouTubeSessionCreator creator = new(config);

string visitorData = await creator.VisitorDataAsync();
string poToken = await creator.ProofOfOriginTokenAsync(visitorData);
string rolloutToken = await creator.RolloutTokenAsync();

To learn more, visit the full Getting Started & Configuration Guide.

How It Works

  • Visitor Data: Session-level identity token
  • Proof of Origin Token: BotGuard-validated, JS-signed token
  • Rollout Token: Determines feature flags and experiments per session

Fore more details, see here.

Credits

This library was made possible thanks to the incredible reverse-engineering work and research by the open-source community, especially those who uncovered and shared insights into YouTube�s internal APIs.

Special thanks to the following projects and individuals:

  • LuanRT/BgUtils - for their extensive description of how PoToken are generated.
  • LuanRT/YouTube.js - for their detailed understanding of the InnerTube API.
  • yt-dlp - for their research of when and where PoTokens are required.
  • Hao Kuang - for their detailed explanation of YouTube's internal API design.
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 127 6/14/2025
1.0.0 184 6/13/2025

- Fixed namespace/class name conflicts
- Updated NuGet packages