r-lib / gmailr

Access the Gmail RESTful API from R.
https://gmailr.r-lib.org
Other
229 stars 56 forks source link

How to get a refresh_token? #152

Closed maelle closed 3 years ago

maelle commented 3 years ago

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.

maelle commented 3 years ago

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.

maelle commented 3 years ago

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.

maelle commented 3 years ago

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

jennybc commented 3 years ago

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
jennybc commented 3 years ago

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

maelle commented 3 years ago

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

maelle commented 3 years ago

Thank you @jennybc, that was the problem!