0

I am trying to run a R script in cron server which connects to my Big query tables and returns some value.

But it fails due to authentication problems. I get this error

Error in httpuv::startServer(use$host, use$port, list(call = listen)) : 
  Failed to create server
Calls: query_exec ... init_oauth2.0 -> oauth_authorize -> oauth_listener -> <Anonymous>
Execution halted

Any work around for this kind of authentication related issues with R in BigQuery? I have heard of httr, don't know if that might solve the problem, if so any idea how do I implement it? my R script is very simple as follows:

library(bigrquery)
project <- "xxx" 
sql <- "SELECT col1 FROM [xxx:yy.zzz]  LIMIT 5"
query_exec(sql, project = project)
user1111
  • 321
  • 2
  • 4
  • 16
  • I am thinking about your last question a bit. And I believe there was one main problem. In each question is necessary show, what you try, show your code. It is no problem if code is wrong (then show also error). Also very common problem is if show code, but no samle data and no expected output. I believe [how to provide a great pandas example](http://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) with [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) can help. – jezrael Mar 18 '18 at 05:56
  • Finally I hope my code help you a bit and if some problem, try ask question. Only hope you are not a lot disappointed... Good luck and happy coding. – jezrael Mar 18 '18 at 06:00
  • 2
    @jezrael- hey man, thanks for your response and your help. But I did the code in a different way after all the controversies that arose. And I think I will put it up on Stackoverflow if you think its fine to do. Thanks :) – user1111 Mar 18 '18 at 13:14

1 Answers1

1

I solved it. By adding this line in the R script:

set_service_token("/pathToTheFile/token.json")

where token.json is a json file which has all your connection credentials that you can get from your google console account of bigquery.

It helps to get the authentication and does the job automatically without any interaction.

user1111
  • 321
  • 2
  • 4
  • 16