Google Drive

Started by golijoe, May 20, 2022, 09:09:14 AM

Previous topic - Next topic

golijoe

I'm running version 2020A and it's been awhile since I've last used Win Batch because of job duties change. I want to be able get a list of PDF file on a Google drive so as to compare to another list and I'm not getting anything to show up.

temp=Environment ("TEMP")

AddExtender("WWWSK44I.DLL",0,"WWWSK64I.DLL")
dir = httpGetDir( "https://drive.google.com/drive/folders/1eD_2MwUL_nlSUmh2bOKqwLZzF_Ljdjre", "" )
list = FileItemize(dir)
Message("", list)
exit


td

You might want to consider spending more time with the Inet extender's documentation. The httpGetDir function does not return a list of a directory's contents.  The Google Drive REST API documentation might be an excellent place to learn what headers and fields need to be included in an HTTP GET verb to get a file listing. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

golijoe

I could not find a way around it so I just have to select all the files in the Google drive and create a short cut to my drive. Then I can run my script but it's one step I wish I didn't have to do but it works for now. 

td

I don't have Google Drive on any system nor intend to install it so I can't provide you with an example. However, here is a link to the REST APIs for Google Drive in case you haven't looked at them yet:

https://developers.google.com/drive/api/v3/reference/

The biggest concern would be performing authentication via the OAuth 2.0  protocol. IIRC, OAuth 2.0 support can be found in the dotNet Framework and is therefore supported by WinBatch CLR hosting. You may or may not need to perform authentication depending on whether or not Google APIs pick up on an existing connection.

Not much help but perhaps a starting point for further investigation.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

golijoe

Thanks I will look into it when I get a chance. I appreciate your help.

stanl

Just run a simple one-liner Rest Request with Powershell. If it works, then WB can probably do it.

ChuckC

As mentioned in previous posts, if you can do it in PowerShell, you can most likely make it work in WinBatch, too.

A Google search for "google drive rest api example powershell" turned some decent reading:

http://rest-examples.chilkat.io/google_drive/powershell/default.cshtml

https://www.example-code.com/powershell/googleDrive.asp

https://www.connorcg.com/uploading-and-downloading-from-google-drive-via-api-with-powershell-and-oauth2.html


stanl


stanl

Quote from: td on May 25, 2022, 07:05:02 AM
OAuth 2.0 support can be found in the dotNet Framework and is therefore supported by WinBatch CLR hosting.


Tony;  as a thread like this opens up several new avenues, would appreciate any insight on where the Web is going with Oauth 2.0?