Adiakys.GoogleLimitedInputAuth.Net 1.0.0

dotnet add package Adiakys.GoogleLimitedInputAuth.Net --version 1.0.0
                    
NuGet\Install-Package Adiakys.GoogleLimitedInputAuth.Net -Version 1.0.0
                    
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="Adiakys.GoogleLimitedInputAuth.Net" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Adiakys.GoogleLimitedInputAuth.Net" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Adiakys.GoogleLimitedInputAuth.Net" />
                    
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 Adiakys.GoogleLimitedInputAuth.Net --version 1.0.0
                    
#r "nuget: Adiakys.GoogleLimitedInputAuth.Net, 1.0.0"
                    
#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.
#:package Adiakys.GoogleLimitedInputAuth.Net@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Adiakys.GoogleLimitedInputAuth.Net&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Adiakys.GoogleLimitedInputAuth.Net&version=1.0.0
                    
Install as a Cake Tool

Google Device Authorization Flow Library for .NET

This library provides a clean and extensible way to authenticate with Google APIs using the OAuth 2.0 Device Authorization Grant, ideal for devices and services that lack a browser or have limited input capabilities.

✨ Features

  • Device Code Flow for OAuth 2.0 with refresh token support
  • Token caching with FileDataStore
  • Automatic access token refresh on expiration
  • Pluggable logging and custom user interaction callbacks
  • Designed for use with Google APIs (e.g., YouTube Data API v3)

πŸ“¦ Installation

Currently not published on NuGet. You can include this library in your project by copying the source or referencing it as a submodule.

πŸš€ Quick Start

Here’s how to authenticate with Google using the Device Authorization flow and create a YouTubeService client:

var credentials = await DeviceCredentials.InitializeAsync(
    clientSecrets: new ClientSecrets
    {
        ClientId = _options.ClientId,
        ClientSecret = _options.ClientSecret
    },
    scope: [YouTubeService.Scope.YoutubeReadonly],
    store: new FileDataStore("gcredentials", fullPath: false),
    callback: ShowCodeToUser,
    logger: _logger,
    cancellationToken: stoppingToken);

var youtube = new YouTubeService(new BaseClientService.Initializer
{
    HttpClientInitializer = credentials,
    ApplicationName = _options.ApplicationName
});

static Task ShowCodeToUser(GDeviceCode code)
{
    Console.WriteLine($"Visit {code.verification_url} and enter the code: {code.user_code}");
    return Task.CompletedTask;
}

πŸ” What this does:

  1. Initialize the credentials using your OAuth 2.0 ClientId and ClientSecret.

  2. Specify the scope you need access to β€” in this case, read-only access to YouTube.

  3. Use a file-based store to persist tokens locally (so the user doesn't have to re-authenticate each time).

  4. Provide a callback function (ShowCodeToUser) to display the verification URL and user code.

  5. Once authorized, it automatically refreshes tokens when needed.

  6. Finally, it creates an authenticated YouTubeService client you can use to call the YouTube Data API.

πŸ“„ License

MIT License. See LICENSE for details.

πŸ‘¨β€πŸ’» Dependencies & References

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.0 141 6/3/2025