Google API client Library for .NET
repository·main·Indexed 23 days ago
https://github.com/googleapis/google-api-dotnet-clientA client library enabling .NET applications to access Google APIs such as Drive, YouTube, and Calendar using OAuth2.0 authentication. It provides strongly-typed, modular NuGet packages for specific services (e.g., Google.Apis.Sheets.v4) and supports .NET Framework 4.6.2+, .NET Standard 2.0, and .NET 6.0+. Note that this library is in maintenance mode and is distinct from the Cloud Client Libraries for .NET designed specifically for Google Cloud Platform services.
What's inside google-api-dotnet-client
- The Google API client library for .NET provides access to a wide range of Google APIs, including Drive, YouTube, Calendar, Storage, and Analytics. It supports OAuth2.0 authentication. The library uses strongly-typed per-API libraries generated via Google's Discovery API.
Overview of Google.Apis.Auth.AspNetCore3
mainThe
Google.Apis.Auth.AspNetCore3NuGet package provides a Google-specific OpenIdConnect authentication handler for ASP.NET Core 3 applications.Key features include:
- Incremental Auth Support: Allows requesting additional scopes as needed.
- Injectable Provider: Defines an
IGoogleAuthProviderinterface that can be injected into your services to supply Google credentials.
Understand the maintenance mode status of the Google API .NET client library
mainThe Google API .NET client library is currently in maintenance mode. This means:
- Feature Set: The libraries are considered mature and complete. No major new features are expected to be added.
- Support: The team continues to support the libraries by fixing bugs and adding minor features necessary to maintain compatibility with ongoing changes to the .NET platform.
- API Updates: New versions of existing API libraries will be released as they become available, and new API libraries will be released as new Google services become available.
Use Google Cloud Client Libraries for Google Cloud Platform APIs
mainIf you are working specifically with Google Cloud Platform services (such as Datastore or Pub/Sub), it is recommended to use the Cloud Client Libraries for .NET instead of this library. The Cloud Client Libraries are the new, idiomatic .NET libraries designed specifically for Google Cloud Platform services.Locate API-specific libraries and generated source code
mainAPI-specific libraries are produced by thegapic-generator-csharp. In this repository, you can find the most recently generated code in theSrc/Generated/directory and the discovery documents used for generation in theDiscoveryJson/directory.Check platform support for the Google API .NET client library
mainThe library does not officially support the following platforms:
- Unity
- Xamarin
- UWP (Universal Windows Platform)
Support for these platforms is not currently provided due to insufficient usage to justify the required technical work and infrastructure. The decision is reviewed periodically.
Find and install API-specific NuGet packages
mainThe Google APIs client library for .NET is modular. Instead of installing one massive library, you should install the specific NuGet package corresponding to the Google API you want to use. Each package follows the naming convention
Google.Apis.[ServiceName].[Version].Commonly used API packages include:
- Google Sheets API v4:
Google.Apis.Sheets.v4 - Cloud Storage JSON API v1:
Google.Apis.Storage.v1 - Cloud Spanner API v1:
Google.Apis.Spanner.v1 - Cloud Speech-to-Text API v1:
Google.Apis.Speech.v1 - Cloud Text-to-Speech API v1:
Google.Apis.Texttospeech.v1
You can find the exact package for your required service in the project's documentation or by searching NuGet for the service name.
- Google Sheets API v4:
Access Developer Documentation and NuGet Packages
mainTo get started with the library, you can use the following resources:
- Get Started Guide: Google API client Library for .NET - Get Started
- API List: Supported APIs
- NuGet Packages: The libraries are published under the
google-apis-packagesprofile on NuGet.
Implement Google.Apis.Auth.AspNetCore3 in your application
mainThe integration test application demonstrates the standard implementation pattern for this library:
- Configuration: Check
Startup.csto see how to register the Google-specific OpenIdConnect authentication handler. - Usage in Controllers: Check
Controllers/HomeController.csto see how to access credentials and perform authenticated actions. - Credential Loading: The sample uses a helper class
ClientInfo.csto load the OAuth client ID and secret from theclient_secrets.jsonfile. In production, you should use a secure method to store and retrieve these credentials.
- Configuration: Check
Run the Google.Apis.Auth.AspNetCore3 Integration Test App
mainYou can run the sample application to see the library in action. This requires ASP.NET Core 3.1 or Visual Studio 2019.
- Clone the repository locally using Git.
- Navigate to the integration test directory:
google-api-dotnet-client/Src/Support/Google.Apis.Auth.AspNetCore3.IntegrationTests - Execute the application using the .NET CLI:
dotnet run - The local web server will start, and a browser should open to the Index page, where you can test various authentication features.
dotnet runReport issues and get support for the Google APIs client Library for .NET
mainIf you encounter bugs or issues within the client library itself, please report them via the GitHub issue tracker.
For questions regarding how to use the client library in your applications, please post your questions to Stack Overflow using the
#google-api-dotnet-clienttag.Install API-specific NuGet packages
mainThe Google APIs client library for .NET is distributed via individual NuGet packages for each specific API. To use a particular Google service, you must install its corresponding NuGet package. For example, to use the Cloud Tasks API v2, you would installGoogle.Apis.CloudTasks.v2.