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

running BoxR from command line - Error in cont$type : $ operator is invalid for atomic vectors #46

Closed
austintrombley opened this issue Mar 16, 2016 · 10 comments

Comments

@austintrombley
Copy link

I am running the following code from command line (works fine in interactive session),

require(boxr)
box_auth()
box_setwd("3862567703")

NULL
[1] "0"
Error in cont$type : $ operator is invalid for atomic vectors
Calls: box_setwd
Execution halted

here is my session info

sessionInfo(package=NULL)
R version 3.1.3 (2015-03-09)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server 2008 R2 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

other attached packages:
[1] sqldf_0.4-10 gsubfn_0.6-6 proto_0.3-10 RSQLite_1.0.0
[5] DBI_0.3.1 RODBC_1.3-12 boxr_0.3.1 RCurl_1.95-4.7
[9] bitops_1.0-6 XLConnect_0.2-11 XLConnectJars_0.2-9

loaded via a namespace (and not attached):
[1] assertthat_0.1 bit_1.1-12 bit64_0.9-5 chron_2.3-47
[5] curl_0.9.3 digest_0.6.8 grid_3.1.3 httr_1.0.0
[9] jsonlite_0.9.17 lattice_0.20-33 lubridate_1.3.3 magrittr_1.5
[13] memoise_0.2.1 plyr_1.8.3 R6_2.1.1 rCharts_0.4.5
[17] Rcpp_0.12.0 RGoogleAnalytics_0.1.1 rJava_0.9-7 RJSONIO_1.3-0
[21] rstudioapi_0.3.1 stringi_0.5-5 stringr_1.0.0 tcltk_3.1.3
[25] tools_3.1.3 whisker_0.3-2 yaml_2.1.13

@brendan-r
Copy link
Collaborator

Hmm. Thanks for the detailed report, though unfortunately I can't reproduce. My hunch is that authentication is failing for you.

Please try:

  • Updating to the latest version install.packages("boxr"), and re-test
  • If the problem persists, please include the message returned by box_auth() (do redact any personal information you like). Your error message is consistent with the auth step not completing successfully.

Brendan

@austintrombley
Copy link
Author

Should I download this again and try?

@austintrombley
Copy link
Author

image

@brendan-r
Copy link
Collaborator

Yes, please update to the latest version.

The problem may be that you are not running an 'interactive session' (you're using Rscript), and box_auth assumes that you are. The appropriate setting in this case would be box_auth(interactive = FALSE). Let me know what you see when you try that.

@austintrombley
Copy link
Author

Brendan,

I thought this might fix it – and I have tried this a few ways, still says it needs a listener?

require(boxr)

BOX_CLIENT_ID = “po1imyvnod3i…."
BOX_CLIENT_SECRET = “IGk9ojEO9TK….."
box_auth(client_id = “po1imyvnod3….", client_secret = “IGk9ojEO9….",interactive=FALSE)
[cid:990B2873-50AE-4BFB-8A95-36571CDCE7B8]

regards,
Austin D. Trombley, MBA
Senior Manager – Business Intelligence
cell: 415-767-6179
[cid:image001.png@01CFEA2B.2E127A90]http://www.prosper.com/

From: Brendan Rocks <notifications@github.commailto:notifications@github.com>
Reply-To: brendan-r/boxr <reply@reply.github.commailto:reply@reply.github.com>
Date: Thursday, April 7, 2016 at 10:43 PM
To: brendan-r/boxr <boxr@noreply.github.commailto:boxr@noreply.github.com>
Cc: Austin Trombley <atrombley@prosper.commailto:atrombley@prosper.com>
Subject: Re: [brendan-r/boxr] running BoxR from command line - Error in cont$type : $ operator is invalid for atomic vectors (#46)

Yes, please update to the latest version.

The problem may be that you are not running an 'interactive session' (you're using Rscript), and box_auth assumes that you are. The appropriate setting in this case would be box_auth(interactive = FALSE). Let me know what you see when you try that.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHubhttps://github.com//issues/46#issuecomment-207225002

CONFIDENTIALITY STATEMENT: This email message, together with all attachments, is intended only for the individual or entity to which it is addressed and may contain legally privileged or confidential information. Any dissemination, distribution or copying of this communication by persons or entities other than the intended recipient, is strictly prohibited, and may be unlawful. If you have received this communication in error please contact the sender immediately and delete the transmitted material and all copies from your system, or if received in hard copy format, return the material to us via the United States Postal Service. Thank you.

@brendan-r
Copy link
Collaborator

Let me know if this works:

  • Remove interactive = FALSE from box_auth()
  • Run your script in an 'interactive mode' (e.g. in Rstudio, or the R console if you're on Windows). The script just needs to get as far as box_auth(). You are likely to be prompted to log-in to your account via a web-browser.
  • Re-run your script via Rscript

Rationale: Under the hood, OAuth2.0 (the standard which box.com uses to authenticate your account) requires that you have something called a 'token', which is a file sent from box.com stored on your machine. To get this, you need to submit your client_id and client_secret and then sign in via a web-browser. A token file is then stored (by default) at ~/.boxr-oauth.

If you're not in an interactive session (e.g. using Rscript) then R/httpuv cannot launch a browser, which means you cannot generate a token. However, by running an interactive session first, the token should be generated on your machine. This means that a non-interactive session can find and 'refresh' the token, without the necessity for the browser validation part.

Let me know if this solves your problem. I should investigate more informative error messages for this case.

@austintrombley
Copy link
Author

Brendan,

I ran the script from Rstudio, and it ran fine. However, when I run it again from command line with box_auth(interactive=FALSE) I still get the same error:
box_auth()
Reading client id from .Renviron
Reading client secret from .Renviron
Auto-refreshing stale OAuth token.
boxr: Authenticated at box.comhttp://box.com/ as Austin Trombley (atrombley@prosper.commailto:atrombley@prosper.com)

#box_fresh_auth()

#install.packages("boxr")
#library(boxr)
#box_fresh_auth()

setwd("C:/Users/atrombley/Desktop/Projects/cost_data_upload")
box_dl("33618399925", overwrite=TRUE)
|======================================================================================================| 100%[1] "C:\Users\atrombley\Desktop\Projects\cost_data_upload\Data_Pull.xlsx"

fn <- "C:/Users/atrombley/Desktop/Projects/cost_data_upload/Data_Pull.xlsx"

file.infohttp://file.info/(fn)
size isdir mode mtime
C:/Users/atrombley/Desktop/Projects/cost_data_upload/Data_Pull.xlsx 996930 FALSE 666 2016-04-08 14:12:15
ctime atime exe
C:/Users/atrombley/Desktop/Projects/cost_data_upload/Data_Pull.xlsx 2016-01-14 11:12:42 2016-01-14 11:12:42 no

require(XLConnect)
require(RCurl)
Loading required package: RCurl
Loading required package: bitops
require(RODBC)
Loading required package: RODBC
require(DBI)
Loading required package: DBI
require(RSQLite)
Loading required package: RSQLite
require(sqldf)
Loading required package: sqldf
Loading required package: gsubfn
Loading required package: proto
Attaching package: ‘gsubfn’
The following object is masked ​_by_​ ‘.GlobalEnv’:
fn
#rm(wb)
wb = loadWorkbook(fn,create=TRUE)
df <- readWorksheet(wb, sheet = "sheet2", header = TRUE)
head(df)
Name Date Refac Refmc Refd.cmhttp://refd.cm/ Cost Impressions Clicks Avg..Position Approvals
1 Brand Terms [search] 2015-01-01 KMMECNT YUEJO 679.12 4108 608 1.2 16
2 Brand Terms [search] 2015-01-02 KMMECNT YUEJO 1319.00 4489 1057 1.3 41
3 Brand Terms [search] 2015-01-03 KMMECNT YUEJO 1047.04 3617 849 1.3 28
4 Brand Terms [search] 2015-01-04 KMMECNT YUEJO 892.82 3446 743 1.3 15
5 Brand Terms [search] 2015-01-05 KMMECNT YUEJO 1801.49 5493 1302 1.3 30
6 Brand Terms [search] 2015-01-06 KMMECNT YUEJO 1649.91 5687 1299 1.3 51
Listings
1 16
2 41
3 28
4 15
5 30
6 51

———————————————————————————————————————
Ran from command line:

[cid:AD58BD95-021C-4D28-B966-5CEDFEE13650]
regards,
Austin D. Trombley, MBA
Senior Manager – Business Intelligence
cell: 415-767-6179
[cid:image001.png@01CFEA2B.2E127A90]http://www.prosper.com/

From: Brendan Rocks <notifications@github.commailto:notifications@github.com>
Reply-To: brendan-r/boxr <reply@reply.github.commailto:reply@reply.github.com>
Date: Friday, April 8, 2016 at 12:53 PM
To: brendan-r/boxr <boxr@noreply.github.commailto:boxr@noreply.github.com>
Cc: Austin Trombley <atrombley@prosper.commailto:atrombley@prosper.com>
Subject: Re: [brendan-r/boxr] running BoxR from command line - Error in cont$type : $ operator is invalid for atomic vectors (#46)

Let me know if this works:

  • Remove interactive = FALSE from box_auth()
  • Run your script in an 'interactive mode' (e.g. in Rstudio, or the R console if you're on Windows). The script just needs to get as far as box_auth(). You are likely to be prompted to log-in to your account via a web-browser.
  • Re-run your script via Rscript

Rationale: Under the hood, OAuth2.0 (the standard which box.com uses to authenticate your account) requires that you have something called a 'token', which is a file sent from box.com stored on your machine. To get this, you need to submit your client_id and client_secret and then sign in via a web-browser. A token file is then stored (by default) at ~/.boxr-oauth.

If you're not in an interactive session (e.g. using Rscript) then R/httpuv cannot launch a browser, which means you cannot generate a token. However, by running an interactive session first, the token should be generated on your machine. This means that a non-interactive session can find and 'refresh' the token, without the necessity for the browser validation part.

Let me know if this solves your problem. I should investigate more informative error messages for this case.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHubhttps://github.com//issues/46#issuecomment-207576677

CONFIDENTIALITY STATEMENT: This email message, together with all attachments, is intended only for the individual or entity to which it is addressed and may contain legally privileged or confidential information. Any dissemination, distribution or copying of this communication by persons or entities other than the intended recipient, is strictly prohibited, and may be unlawful. If you have received this communication in error please contact the sender immediately and delete the transmitted material and all copies from your system, or if received in hard copy format, return the material to us via the United States Postal Service. Thank you.

@brendan-r
Copy link
Collaborator

brendan-r commented Apr 18, 2016

That's not the same error. The text appears to show you authenticating successfully, and the output of R code running, no..?

@austintrombley
Copy link
Author

I have reduced the code now to just two lines to show the issue (it runs fine from interactive window).

require(boxr)
box_auth()

----->
Loading required package: boxr
Welcome to boxr 0.2.9!
Bug reports: https://github.com/brendan-R/boxr/issues

See vignette('boxr') for a short guide on connecting your box.com account to R.
Please enter your box client id. If you don't have one
see the documentation at ?box_auth, and hit ENTER to exit.

NULL
Error: oauth_listener() needs an interactive environment.
Execution halted


require(boxr)
box_auth(interactive=FALSE)
----->
Loading required package: boxr
Welcome to boxr 0.2.9!
Bug reports: https://github.com/brendan-R/boxr/issues

See vignette('boxr') for a short guide on connecting your box.com account to R.
Error in box_auth(interactive = FALSE) :
box.com authorization unsuccessful; client id and/or secret not found.
See ?box_auth for help!

Execution halted

require(boxr)
box_auth(client_id = "po1imyvnod3iyl4ysan......", client_secret = "IGk9ojEO9TKeHN......",interactive=FALSE)
----->

Loading required package: boxr
Welcome to boxr 0.2.9!
Bug reports: https://github.com/brendan-R/boxr/issues

See vignette('boxr') for a short guide on connecting your box.com account to R.
Error: oauth_listener() needs an interactive environment.
Execution halted

@brendan-r
Copy link
Collaborator

Hey Austin,

Assuming you got this working in the end. Closing this issue for the time being.

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

No branches or pull requests

2 participants