Sub UploadFileToDrive(filePath As String, fileName As String, mimeType As String)
' Step 1: Authenticate the request
Dim authUrl As String = "https://accounts.google.com/o/oauth2/token"
Dim authParams As Map
authParams.Initialize
authParams.Put("code", "YOUR_AUTHORIZATION_CODE")
authParams.Put("client_id", "YOUR_CLIENT_ID")
authParams.Put("client_secret", "YOUR_CLIENT_SECRET")
authParams.Put("redirect_uri", "urn:ietf:wg:oauth:2.0:oob")
authParams.Put("grant_type", "authorization_code")
Dim authResponse As String = HttpUtils2.ExecuteHttpPost(authUrl, authParams)
Dim accessToken As String = Regex.Matcher("access_token"":""(.+?)""", authResponse).Group(1)
' Step 2: Upload the file
Dim uploadUrl As String = "https://www.googleapis.com/upload/drive/v3/files?uploadType=media"
Dim uploadHeaders As Map
uploadHeaders.Initialize
uploadHeaders.Put("Authorization", "Bearer " & accessToken)
uploadHeaders.Put("Content-Type", mimeType)
Dim uploadResponse As String = HttpUtils2.ExecuteHttpRequest("POST", uploadUrl, Null, uploadHeaders, File.ReadAllBytes(filePath))
Log(uploadResponse)
End Sub