-
-
Notifications
You must be signed in to change notification settings - Fork 494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refresh Tokens for Gmail access using GoogleAuthenticator #471
Comments
Hi shajvarg, I'm attaching my own module that I use for handling Google API calls. Feel free to use this, and to change it however you like. Some notes:
I hope that helps. |
Thanks Richard for the code and the detailed help. I couldn't find this anywhere else also.. Can you please let me know the actual value of NonHttpCode? Thanks again |
Oh yes, I forgot. I have my own modified version of WebClient.Execute, which handles errors differently. I dislike the way that standard VBA-Web handles errors raised by WinHTTP. If you don't want to change WebClient.Execute, please just delete the references to NonHttpCode. Alternatively, use my version of the WebClient module (attached) and add a declaration of NonHttpCode to the WebHelpers module, like this:
|
Thanks Richard once again.. I also got IE to work.. that took more time as there are different reasons to the unsecure browser issue. I took an easy way out and deleted the internet explorer key section in USER section in the registry which worked. the other being looking at policies section.. Shaju |
Hi Shaju. I'm glad you managed to get IE to work. I hope I never have to use IE again, but I'm concerned I might need it in the future. Not all APIs provide the option to copy the the Authorization Code. |
Hi Richard, |
Hi,
where sMsg is a proper MIME formatted email message. This particular code uses hope it helps |
You can also add an example of how to create a MIME message ? |
so the example below is an actual MIME msg.. except the attachment is
truncated.
if u are sending only a message without attachment you can send till the
first boundary and end it with boundary --
https://developers.google.com/gmail/api/guides/sending
this link should get you going.
Shaju
Content-Type: multipart/mixed; boundary=_NextPart_9E20D285C001973CCA9D
MIME-Version: 1.0
To: ***@***.***
From: ***@***.***
Subject: Email with attachment
…--_NextPart_9E20D285C001973CCA9D
Content-Type: text/plain; charset="UTF-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Pls see the files attached
--_NextPart_9E20D285C001973CCA9D
Content-Type: application/vnd.ms-excel; name="Example.xls"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="Example.xls"
0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAADAAAAAQAAAAAA
AAAAEAAA7AAAAAIAAAD+////AAAAAAAAAABiAAAA/wAAAP//////////////////////////
--_NextPart_9E20D285C001973CCA9D--
On Thu, 24 Mar 2022 at 20:32, hnsywnwtsly ***@***.***> wrote:
You can also add an example of how to create a MIME message ?
—
Reply to this email directly, view it on GitHub
<#471 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AYDE2QNW37PU7TFESMMFTUTVBR7YRANCNFSM5QB6T3XQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
This is the server response I get And that's the code I use
` What's wrong with my code? |
u have to change the baseurl of gmailclient to "https://www.googleapis.com/upload/gmail/v1/" |
It seems to be moving in the right direction. |
Hi Richard, Thanks |
Just as an aside, you'll want to be careful with refresh tokens in apps that aren't very secure (like VBA apps). Native apps can take advantage of OS-level encryption to keep the refresh tokens safe(r). The options for VBA to do the same are more limited. |
Apparently there is no unequivocal answer. |
Agree, But we can easily encrypt it and store |
True.. It appears as long as the code is in testing phase, the refresh tokens last for 7 days only. If you submit for verification then it remains valid without expiring.. Issue is for vba code... how can we submit for verification.. it is not an app.. |
The problem is solved, see here |
Hi,
I am grateful for the great tools for using webservices with VBA.
I tried to access Gmail using these tools.
Everything works but the access tokens time out as they are supposed to.
I wanted to know if there is a way to get "refresh tokens" without user intervention using "IE explorer" page once the user has confirmed access to gmail.
In the current gmail.bas the user has to be reauthenticated everytime after the webclient object is released from memory.
thanks in advance
The text was updated successfully, but these errors were encountered: