WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: golijoe on May 20, 2022, 09:09:14 AM

Title: Google Drive
Post by: golijoe on May 20, 2022, 09:09:14 AM
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

Title: Re: Google Drive
Post by: td on May 20, 2022, 01:30:33 PM
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. 
Title: Re: Google Drive
Post by: golijoe on May 24, 2022, 11:25:29 AM
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. 
Title: Re: Google Drive
Post by: td on May 25, 2022, 07:05:02 AM
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/  (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.
Title: Re: Google Drive
Post by: golijoe on May 25, 2022, 08:41:23 AM
Thanks I will look into it when I get a chance. I appreciate your help.
Title: Re: Google Drive
Post by: stanl on May 25, 2022, 10:19:05 AM
Just run a simple one-liner Rest Request with Powershell. If it works, then WB can probably do it.
Title: Re: Google Drive
Post by: ChuckC on May 26, 2022, 10:01:46 AM
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

Title: Re: Google Drive
Post by: stanl on May 27, 2022, 02:34:15 AM
and specific to Op's ask:


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

Title: Re: Google Drive
Post by: stanl on May 29, 2022, 10:03:52 AM
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?