Skip to content
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

Getting started #1

Closed
lcolladotor opened this issue Sep 3, 2014 · 3 comments
Closed

Getting started #1

lcolladotor opened this issue Sep 3, 2014 · 3 comments

Comments

@lcolladotor
Copy link

Hello,

I am probably missing something obvious, but I am having trouble getting started with using gmailr.

  • Went to https://cloud.google.com/console#/project
  • I created a project, called it "Access-gmailr"
  • Opened the project. Then under "APIs & Auth" and in the sub-menu "API" I enabled the Gmail API. That automatically enabled a couple other APIs as shown below.
    screen shot 2014-09-03 at 1 31 15 pm
  • Then under "APIs & Auth" and in the sub-menu "Credentials" I downloaded the "Compute Engine App Engine" json. Tried using it and got a 400 error.
    screen shot 2014-09-03 at 1 27 52 pm
  • Also under "APIs & Auth" and in the sub-menu "Credentials" created a new client ID and selected the "service account" option. This didn't work either and lead to another 400 error.
    screen shot 2014-09-03 at 1 36 44 pm

So, hm... what am I missing?

I did check that under the "Permissions" menu all the service accounts have the permission to edit. The Gmail API auth page didn't help me either.

Thanks!

> sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] gmailr_0.0.1

loaded via a namespace (and not attached):
[1] base64enc_0.1-2 httpuv_1.3.0    httr_0.4        jsonlite_0.9.10 Rcpp_0.11.2     RCurl_1.95-4.3  stringr_0.6.2   tools_3.1.0 
@luiscape
Copy link

luiscape commented Sep 4, 2014

Hi there @lcolladotor, apologies for the incomplete answer. I believe part of your issue is when you select the kind of authorization you want from Google. You have to select "installed applications", then Google will give you a json to download.

Before you make your query, though, make sure you authorize the 'Consent screen' under APIs & auth. Without that you'll run into an 401 error.

I hope it helps ...

@lcolladotor
Copy link
Author

Hi,

Thank you for the input @luiscape, I got farther this time.

So, under "APIs & Auth", sub-menu "Credentials" I created a new client ID of the "installed applications" type (selecting "other"). Downloaded the new json file and... then got another error.

Steps followed

I made sure to clear the directory before proceeding as shown below.

$ rm .Rapp.history
$ rm .httr-oauth
$ rm .gitignore
$ R

Everything seemed to go fine, as I did get to authorize the app and got the message on the browser saying it was fine.

> library(gmailr)
> gmail_auth("new-installed-applications.json")
Use a local file to cache OAuth access credentials between R sessions?
1: Yes
2: No

Selection: 2
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort

screen shot 2014-09-04 at 4 13 43 pm
screen shot 2014-09-04 at 4 13 51 pm

But within 1 second of authorizing the app in the browser, an error popped up in the R console.

Authentication complete.
Error in gmail_auth("new-installed-applications.json") :
  cannot change value of locked binding for 'google_token'
> traceback()
1: gmail_auth("new-installed-applications.json")

Got any tips on what to do now? Seems like it could be related to Binding and Environment Locking.

Session info

> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] gmailr_0.0.1   colorout_1.0-2

loaded via a namespace (and not attached):
[1] base64enc_0.1-2 httpuv_1.3.0    httr_0.4        jsonlite_0.9.10
[5] Rcpp_0.11.2     RCurl_1.95-4.3  stringr_0.6.2

@jimhester
Copy link
Member

I can reproduce this, the problem and fix is detailed at http://adv-r.had.co.nz/Environments.html#explicit-envs

The reason that I did not notice this issue when I was developing the package is I was using devtools load_all function, which loads all the objects in the user namespace rather than package namespace. Thank you for reporting the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants