Google Drive API in visual basic

  • Thread starter Thread starter TimeFluid
  • Start date Start date
T

TimeFluid

Guest
I've been trying to find out how to get the Google Drive API to work in visual basic. I'm wanting to use this code for my notepad program. I just want it to upload the notes after pushing the upload button on my form. I've also found other pages showing how to do it, but there code didn't work. Here is the API page [LINK], but it doesn't show code for VB. I've been messing around with code and got this..

Imports Google.Apis.Drive.v3
Imports Google.Apis.Auth.OAuth2
Imports Google.Apis.Drive.v3.Data
Imports Google.Apis.Services
Imports System.Threading


Public Class Form1

Private Service As DriveService = New DriveService

Private Sub CreateService()
Dim ClientId = "Client ID"
Dim ClientSecret = "Client secret"
Dim MyUserCredential As UserCredential = GoogleWebAuthorizationBroker.AuthorizeAsync(New ClientSecrets() With {.ClientId = ClientId, .ClientSecret = ClientSecret}, {DriveService.Scope.Drive}, "user", CancellationToken.None).Result
Service = New DriveService(New BaseClientService.Initializer() With {.HttpClientInitializer = MyUserCredential, .ApplicationName = "Google Drive VB Dot Net"})
End Sub

Private Sub UploadFile(FilePath As String)
Dim TheFile As New File()
TheFile.Name = TextBox3.Text
TheFile.Description = "Google Drive API Test Program"
TheFile.MimeType = "text/plain"
End Sub
End Class


.... I'm not sure where to go from here.. thanks so much. :D (I'm using Google.Apis.Drive.v3 from NuGet btw)

Continue reading...
 
Back
Top