Request = (fileMetadata, stream, "image/jpeg") Using (var stream = new FileStream(path, FileMode.Open)) Var fileMetadata = new 3.Data.File() įileMetadata.Name = Path.GetFileName(path) We just need to read creadential.json file then return back instance of DriverService. Var service = new DriveService(new BaseClientService.Initializer()īefore we working with Google Drive API we need to authenticate. New FileDataStore(credPath, true)).Result GoogleClientSecrets.Load(stream).Secrets, String credPath = Environment.GetFolderPath() ĬredPath = Path.Combine(credPath, "./credentials/credentials.json") Ĭredential = GoogleWebAuthorizationBroker.AuthorizeAsync( New FileStream("credentials.json", FileMode.Open, FileAccess.Read)) Private DriveService GetDriveServiceInstance() Private string Scopes = īelow is the full list of scope that Google Drive API currently support granted full control of google drive api First in the class I need to let Google Drive API know what scopes I granted for my application Put this comman inside package manager console
#Google drive api python install#
Let get start.īefore you process please make sure you have basic concept understanding how Google Drive API work and what it can offer and follow a setup to get credentials.json file and put it into your app folderīefore we begin we need to install package. So basically I implement 2 functionality that is Upload and Download. Lately I have been working with Google Drive API to upload image for post in open source project Awesome CMS Core.