1

I configured my oauth succesfully with gmailr, the following code worked

require(gmailr)

gm_auth_configure(path="E:/SOME_NAME.json")

test_email <- mime(
To = "someone@something.com",
From = "someone@gmail.com",
Subject = "this is just a gmailr test",
body = "Can you hear me now?")
gm_send_message(test_email)

Then I installed blastula and configured my gmail oauth again with:

create_email_creds_file(
user = "someone@gmail.com",
password = "************",
provider = "gmail")

Now when I run:

require(gmailr)
gm_auth_configure(path="E:/SOME_NAME.json")
test_email <- mime(
To = "someone@somewhere.com",
From = "someone@gmail.com",
Subject = "this is just a gmailr test",
body = "Can you hear me now?")
gm_send_message(test_email)

I get error:

Auto-refreshing stale OAuth token. Error in gzfile(file, mode) : cannot open the connection In addition: Warning messages: 1: Unable to refresh token: invalid_grant Token has been expired or revoked. 2: In gzfile(file, mode) :cannot open file 'C:/Users/.R/gargle/gargle-oauth': it is a directory

How do I undo the blastula oauth and get back to my originally working gmailr oauth file / i.e. how do i start over and get gm_auth_configure to point to the location of my oauth file ?

user2948714
  • 671
  • 2
  • 9
  • 13
  • invalid_grant normally means that the token you are sending is either invalid or expired. – Linda Lawton - DaImTo Oct 09 '19 at 06:17
  • 1
    Thanks DalmTo for your comment. The original oath file I used with gmailr is still valid, problem is that the oath file location from blastula pointed the authentication to a wrong location. Adding gm_auth(cache=".secret") resets the oath and takes you through the authentication with google again and all works well now. – user2948714 Oct 09 '19 at 16:47

1 Answers1

2

I found how to reset back to the original oath file, gm_auth(cache=".secret") does the trick. This now takes you back to the google page to link back to your original oauth file after which everything works well again. So the full code is:

gm_auth_configure(path="E:/SOME_NAME.json")
gm_auth(cache=".secret")

test_email <- mime(
To = "someone@something.com",
From = "someone@gmail.com",
Subject = "this is just a gmailr test",
body = "Can you hear me now?")
gm_send_message(test_email)

This now reverts back to the original oath file and all works perfect again.

user2948714
  • 671
  • 2
  • 9
  • 13