Skip to content

Latest commit

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

GoogleAPI-Library

This library is an add-on to the existing library from Google, which allows you to interact programmatically with various Google services, such as Google Drive, Google Sheets

The goal of this project is to make it easier to interact with Google services, and to reduce code duplication in projects where interaction with Google is required.

⚠️ Not full functionality

Library functionality is added as needed. Because of this, the library does not implement all of the available functionality.

Google services used:

  1. Google Drive
  2. Google Sheets

🚀 How to use

Currently, the library provides two classes for interfacing with Google services:

GoogleDriveManagerdrive=newGoogleDriveManager(DriveService);GoogleSheetsManagersheets=newGoogleSheetsManager(SheetsService);

Every class that interacts with Google takes a descendant of the BaseClientService class in its constructor

For Drive API this is DriveService, for Sheets API SheetsService

Google Sheets

GoogleSheetOptionsoptions=newGoogleSheetOptions{SheetId="Your Sheet id",SheetRange="Your Sheet Name"};// Reading data from Google SheetGoogleSheetsManagergoogleSheetsManager=newGoogleSheetsManager(SheetsService);vardata=awaitgoogleSheetsManager.ReadAsync(options);// Writing data into Google SheetsvardataToInsert=newList<IList<object>>{newobject[]{"data","data2","data3"}};awaitgoogleSheetsManager.WriteAsync(options,dataToInsert);

Google Drive

Get subfolders in the main folder:

stringmainFolderId="Your main folder ID";GoogleDriveManagermanager=newGoogleDriveManager(DriveService);List<FolderModel>folders=awaitmanager.Folders.GetFolders(mainFolderId);foreach(FolderModelfolderinfolders){Console.WriteLine($"name {folder.Name} id: {folder.Id}");}

Add Permissions to Folder:

GoogleDriveManagermanager=newGoogleDriveManager(DriveService);awaitmanager.Permissions.AddUserToFile(PermissionRole.writer,PermissionsType.user,"mail@gmail.com","Folder ID",false);

To use the Service account for Google Drive:

GoogleCredentialcredential=GoogleCredential.FromFile(SecretPath).CreateScoped(DriveService.ScopeConstants.Drive);DriveServiceservice=newDriveService(newBaseClientService.Initializer(){HttpClientInitializer=credential,ApplicationName=AppName});

🤝 Contributing

Contributions, issues and feature requests are welcome. Feel free to check issues page if you want to contribute.

About

Library that allows you to interact with google services

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages