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
<PackageReference Include="Adiakys.GoogleLimitedInputAuth.Net" Version="1.0.0" />
<PackageVersion Include="Adiakys.GoogleLimitedInputAuth.Net" Version="1.0.0" />
<PackageReference Include="Adiakys.GoogleLimitedInputAuth.Net" />
paket add Adiakys.GoogleLimitedInputAuth.Net --version 1.0.0
#r "nuget: Adiakys.GoogleLimitedInputAuth.Net, 1.0.0"
#:package Adiakys.GoogleLimitedInputAuth.Net@1.0.0
#addin nuget:?package=Adiakys.GoogleLimitedInputAuth.Net&version=1.0.0
#tool nuget:?package=Adiakys.GoogleLimitedInputAuth.Net&version=1.0.0
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:
Initialize the credentials using your OAuth 2.0 ClientId and ClientSecret.
Specify the scope you need access to β in this case, read-only access to YouTube.
Use a file-based store to persist tokens locally (so the user doesn't have to re-authenticate each time).
Provide a callback function (ShowCodeToUser) to display the verification URL and user code.
Once authorized, it automatically refreshes tokens when needed.
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 | Versions 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. |
-
net9.0
- ErrorOr (>= 2.0.1)
- Google.Apis.Auth (>= 1.69.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.5)
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 |