Working with GDrive (1 Viewer)

smig

Registered User.
Local time
Today, 20:44
Joined
Nov 25, 2009
Messages
2,209
Anyone here managed to work with GoogleDrive ?
I would like to upload files to GDrive, using VBA (XML)

I do work with GoogleMaps, but can't understand the GDrive API :(
 

nhorton79

Registered User.
Local time
Tomorrow, 07:44
Joined
Aug 17, 2015
Messages
147
I believe Google Drive uses oAuth2 to get an access token using your client id and secret.

Honestly, I’ve been using the Chilkat library which has a heap of useful connections for vbscript which are fully adaptable for VBA.

www.example-code.com/vbscript/

It is a paid library $295 USD, but you get the library for use in unlimited projects and in multiple (read “every”) language. And figure it would take me ages to sort out these API calls myself in VBA.

Note: I’m in no way affiliated with Chilkat. But just found an awesome new library for working with web API calls.


Sent from my iPhone using Tapatalk
 

nhorton79

Registered User.
Local time
Tomorrow, 07:44
Joined
Aug 17, 2015
Messages
147
There are free libraries for working oAuth and oAuth2 though like Vba web

https://github.com/VBA-tools/VBA-Web

But the good thing with Chilkat is they have predefined code samples. Although you could adapt their code to work with VBA web


Sent from my iPhone using Tapatalk
 

smig

Registered User.
Local time
Today, 20:44
Joined
Nov 25, 2009
Messages
2,209
I believe Google Drive uses oAuth2 to get an access token using your client id and secret.

Honestly, I’ve been using the Chilkat library which has a heap of useful connections for vbscript which are fully adaptable for VBA.

www.example-code.com/vbscript/

It is a paid library $295 USD, but you get the library for use in unlimited projects and in multiple (read “every”) language. And figure it would take me ages to sort out these API calls myself in VBA.

Note: I’m in no way affiliated with Chilkat. But just found an awesome new library for working with web API calls.


Sent from my iPhone using Tapatalk
Do you have an example of some code ?
 

nhorton79

Registered User.
Local time
Tomorrow, 07:44
Joined
Aug 17, 2015
Messages
147
Did you have a look at the pages with examples I gave you links to?

On the Chilkat page there are heaps of VBScript examples (which are very similar VBA, the main exception being that you'll find most VBS variables aren't declared and are treated as Variants).

The other thing with Chilkat is that they have a 30 day trial for you to test the library to ensure it meets your needs. This is what I did and ended up purchasing after about a week because I realised that the dlls and premade examples were worth it.

Alternatively, if you wanted to go the VBA-Web route, then there is the GMail authenticator under the examples directory that might likely give you some usable code that could be tweaked to suit GDrive rather easily.
 

smig

Registered User.
Local time
Today, 20:44
Joined
Nov 25, 2009
Messages
2,209
Did you have a look at the pages with examples I gave you links to?

On the Chilkat page there are heaps of VBScript examples (which are very similar VBA, the main exception being that you'll find most VBS variables aren't declared and are treated as Variants).

The other thing with Chilkat is that they have a 30 day trial for you to test the library to ensure it meets your needs. This is what I did and ended up purchasing after about a week because I realised that the dlls and premade examples were worth it.

Alternatively, if you wanted to go the VBA-Web route, then there is the GMail authenticator under the examples directory that might likely give you some usable code that could be tweaked to suit GDrive rather easily.
This link is not working, for me
www.example-code.com/vbscript/
 

nhorton79

Registered User.
Local time
Tomorrow, 07:44
Joined
Aug 17, 2015
Messages
147
There is a ton of links down the sidebar for different technologies.
 

nhorton79

Registered User.
Local time
Tomorrow, 07:44
Joined
Aug 17, 2015
Messages
147
Yes. But it’s easy to distribute and register these in your database setup. To be fair my apps only have about 30 front-end users but the setup should be the same regardless (although they’re all on W10 which is nice that I don’t have to faff about with multiple OS).

If that’s not your thing, then of course there are the free oAuth2 authenticates on the VBA-Web Github page.
Will likely require a little more adaptation but certainly a viable option and may be able to be incorporated/adapted using some of the Chilkat code as a base?..


Sent from my iPhone using Tapatalk
 

smig

Registered User.
Local time
Today, 20:44
Joined
Nov 25, 2009
Messages
2,209
I'm trying this code to get a list of files, but it's not working :(
I get a Not Found response
error - 404
Same response even if I remove the ID and password

Code:
strXML = "https://www.googleapis.com/auth/drive/files"

strXML = strXML & "&client-id=" & MyGoogleUserName@gmail.com
strXML = strXML & "&secret=" & MyGooglePass

Set xmlHTTP = CreateObject("MSXML2.ServerXMLHTTP")

With xmlHTTP
    .Open "GET", strXML, False
    .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    .setRequestHeader "Content-Length", Len("Request=" & strXML)
    .send (strXML)
End With

msgbox xmlHTTP.responseText
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 18:44
Joined
Jul 9, 2003
Messages
16,244
Hi Tal,

I follow Bruce mcphersons website desktop liberation'-

http://ramblings.mcpher.com/

It's mostly based around Excel. I have on several occasions tried to adapt Bruce's code to get it working with MS Access without success.

One mistake I recall making was that I assumed the code was in a class module when in fact it was in a standard module. I may got that the wrong way round!

I thought there might be something useful on the site.

Sent from Newbury UK
 

smig

Registered User.
Local time
Today, 20:44
Joined
Nov 25, 2009
Messages
2,209
Hi Tal,

I follow Bruce mcphersons website desktop liberation'-

http://ramblings.mcpher.com/

It's mostly based around Excel. I have on several occasions tried to adapt Bruce's code to get it working with MS Access without success.

One mistake I recall making was that I assumed the code was in a class module when in fact it was in a standard module. I may got that the wrong way round!

I thought there might be something useful on the site.

Sent from Newbury UK

Thanks
can I simply put this Java code into VBA module ?

Is there no simple XML code to do that ?
I'm using XML to interact google Maps.

Learning JAVA is not my no.1 priority now :rolleyes:
 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:44
Joined
Oct 29, 2018
Messages
21,358
I'm trying this code to get a list of files, but it's not working :(
I get a Not Found response
error - 404
Same response even if I remove the ID and password

Code:
strXML = "https://www.googleapis.com/auth/drive/files"

strXML = strXML & "&client-id=" & MyGoogleUserName@gmail.com
strXML = strXML & "&secret=" & MyGooglePass

Set xmlHTTP = CreateObject("MSXML2.ServerXMLHTTP")

With xmlHTTP
    .Open "GET", strXML, False
    .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    .setRequestHeader "Content-Length", Len("Request=" & strXML)
    .send (strXML)
End With

msgbox xmlHTTP.responseText
Error 404 is typically a "page not found" error, which usually means a bad URL address. For example, entering
https://www.googleapis.com/auth/drive/files on my browser's address bar gave me a 404 error.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 18:44
Joined
Jul 9, 2003
Messages
16,244
Thanks

can I simply put this Java code into VBA module ?



Is there no simple XML code to do that ?

I'm using XML to interact google Maps.



Learning JAVA is not my no.1 priority now :rolleyes:

My vague recollection of the way Bruce does it is he found a class module (possibly just a module) I had assumed it was a class module, hence my mistake, like I said earlier I may have around the wrong way.

I believe the module converts between JSON and VBA...

But I'm thinking back a couple of years ago. I was unsuccessful in getting it to work with MS Access...

Sent from Newbury UK
 

nhorton79

Registered User.
Local time
Tomorrow, 07:44
Joined
Aug 17, 2015
Messages
147
Thanks for that link Gizmo!
I’ve always hated using scripting for JS in VBA.
This looks soo much nicer and easier.


Sent from my iPhone using Tapatalk
 

smig

Registered User.
Local time
Today, 20:44
Joined
Nov 25, 2009
Messages
2,209
Thanks for that link Gizmo!
I’ve always hated using scripting for JS in VBA.
This looks soo much nicer and easier.


Sent from my iPhone using Tapatalk
What is nicer and easier ?
Can you help me with this ?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:44
Joined
Oct 29, 2018
Messages
21,358
Yes, I know
can't make it to work :(
Well, first of all, I am thinking you'll need to find the correct URL to use for your code. At least, if you get a different error, you'll be able figure it out. But with a 404 error, not sure what there is to figure out. Good luck!
 

smig

Registered User.
Local time
Today, 20:44
Joined
Nov 25, 2009
Messages
2,209
Well, first of all, I am thinking you'll need to find the correct URL to use for your code. At least, if you get a different error, you'll be able figure it out. But with a 404 error, not sure what there is to figure out. Good luck!
Thanks
Can't figure out what's not working :(
 

Users who are viewing this thread

Top Bottom