r-lib/gmailr

How to get a refresh_token?

maelle opened this issue · 7 comments

My question might be related to #143 (i.e. maybe I chose the wrong setting somewhere?)

I have realized I can't use gmailr with gm_auth(cache = FALSE) because the token I get has no refresh token.

I have created my own app and use

gm_auth_configure(
  key = "blablabla.apps.googleusercontent.com",
  secret = "sEcReT",
  path = ""
)

Everything works fine i.e. I can send emails, but only if I don't try using a cached token.

Note that if I run gargle::token_fetch(scopes = "https://www.googleapis.com/auth/userinfo.email"), I obtain a refresh token so I'm pretty sure something in my app settings is wrong.

I have tried removing access to the app after reading https://stackoverflow.com/questions/10827920/not-receiving-google-oauth-refresh-token, which didn't help.

I'm wondering whether it has to do with the publication status, maybe one needs a public production app.

What type of app did you create? You want "Desktop" and that is VERY IMPORTANT.

Screen Shot 2021-05-04 at 9 14 53 AM

Screen Shot 2021-05-04 at 9 15 48 AM

No, getting a refresh token should work just fine for you, i.e. this has nothing to do with the app being verified.

Aaah that must be it, I'll retry asap, thanks a ton!

Thank you @jennybc, that was the problem!