reichlab / forecast-repository

Codebase for Zoltar forecast repository
https://zoltardata.com/
GNU General Public License v3.0
6 stars 3 forks source link

Unable to make connection to Zoltar in R #291

Closed wadspen closed 3 years ago

wadspen commented 3 years ago

I'm trying to load data from the COVID-19 forecast hub onto my personal machine. To make the connection to Zoltar I run

library(zoltr) zoltar_connection <- new_connection() zoltar_authenticate(zoltar_connection, Sys.getenv("Z_USERNAME"), Sys.getenv("Z_PASSWORD")) zoltar_connection

but I get the error

get_token(): POST: https://zoltardata.com/api-token-auth/ Error in get_token(self) : Bad Request (HTTP 400).

matthewcornell commented 3 years ago

Hi. Sorry you're having trouble. Are you setting the two environment variables to your account's information? Also, are you using the latest version in github, not the CRAN one? Thanks --matt


Matthew Cornell, M.S. ( cornell@umass.edu | 413-626-3621 ) Senior Research Software Engineer Department of Biostatistics and Epidemiology School of Public Health & Health Sciences UMass Amherst


From: swads96 notifications@github.com Sent: Thursday, March 4, 2021 10:50 PM To: reichlab/forecast-repository forecast-repository@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [reichlab/forecast-repository] Unable to make connection to Zoltar in R (#291)

I'm trying to load data from the COVID-19 forecast hub onto my personal machine. To make the connection to Zoltar I run

library(zoltr) zoltar_connection <- new_connection() zoltar_authenticate(zoltar_connection, Sys.getenv("Z_USERNAME"), Sys.getenv("Z_PASSWORD")) zoltar_connection

but I get the error

get_token(): POST: https://zoltardata.com/api-token-auth/ Error in get_token(self) : Bad Request (HTTP 400).

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/reichlab/forecast-repository/issues/291, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAH4OF6HTAWJ3JNFH2NUZF3TCBIIZANCNFSM4YUO5EQQ.

wadspen commented 3 years ago

I installed the github version with

install.packages("devtools") devtools::install_github("reichlab/zoltr", force=TRUE)

And yes I used the username and password that I have to log in to Zoltar.


From: Matthew Cornell notifications@github.com Sent: Friday, March 5, 2021 11:41 AM To: reichlab/forecast-repository forecast-repository@noreply.github.com Cc: Wadsworth, Spencer G [STAT] sgw96@iastate.edu; Author author@noreply.github.com Subject: Re: [reichlab/forecast-repository] Unable to make connection to Zoltar in R (#291)

Hi. Sorry you're having trouble. Are you setting the two environment variables to your account's information? Also, are you using the latest version in github, not the CRAN one? Thanks --matt


Matthew Cornell, M.S. ( cornell@umass.edu | 413-626-3621 ) Senior Research Software Engineer Department of Biostatistics and Epidemiology School of Public Health & Health Sciences UMass Amherst


From: swads96 notifications@github.com Sent: Thursday, March 4, 2021 10:50 PM To: reichlab/forecast-repository forecast-repository@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [reichlab/forecast-repository] Unable to make connection to Zoltar in R (#291)

I'm trying to load data from the COVID-19 forecast hub onto my personal machine. To make the connection to Zoltar I run

library(zoltr) zoltar_connection <- new_connection() zoltar_authenticate(zoltar_connection, Sys.getenv("Z_USERNAME"), Sys.getenv("Z_PASSWORD")) zoltar_connection

but I get the error

get_token(): POST: https://zoltardata.com/api-token-auth/ Error in get_token(self) : Bad Request (HTTP 400).

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/reichlab/forecast-repository/issues/291, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAH4OF6HTAWJ3JNFH2NUZF3TCBIIZANCNFSM4YUO5EQQ.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/reichlab/forecast-repository/issues/291#issuecomment-791575207, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANBGYLN7T5ZCUFFIIJCA3BTTCEJVLANCNFSM4YUO5EQQ.

matthewcornell commented 3 years ago

I wonder if it's an environment variable issue. Others have had trouble getting R to access them properly.

If you run Sys.getenv(), do you see the two environment variables and their values? And are those values the ones you use to log into https://www.zoltardata.com/ ?

Let me know the date and time to the minute that you next try it, OK? I'll see if there's anything in the logs.

wadspen commented 3 years ago

There are a number of environment variables that I can see, but none of them match what I use to login to zoltardata.com.

I just ran this code again

devtools::install_github("reichlab/zoltr", force=TRUE) library(zoltr) zoltar_connection <- new_connection() zoltar_authenticate(zoltar_connection, Sys.getenv("xxxx"), Sys.getenv("xxxx"))

It was run at 3/10/21 3:49:11 CST


From: Matthew Cornell notifications@github.com Sent: Tuesday, March 9, 2021 3:28 PM To: reichlab/forecast-repository forecast-repository@noreply.github.com Cc: Wadsworth, Spencer G [STAT] sgw96@iastate.edu; Author author@noreply.github.com Subject: Re: [reichlab/forecast-repository] Unable to make connection to Zoltar in R (#291)

I wonder if it's an environment variable issue. Others have had trouble getting R to access them properly.

If you run Sys.getenv(), do you see the two environment variables and their values? And are those values the ones you use to log into https://www.zoltardata.com/ ?

Let me know the date and time to the minute that you next try it, OK? I'll see if there's anything in the logs.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/reichlab/forecast-repository/issues/291#issuecomment-794478135, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANBGYLPQOPSYHTQYWEI4BXTTC2AHFANCNFSM4YUO5EQQ.

matthewcornell commented 3 years ago

Sorry I wasn't clear. The environment variables must be accessible to R in order for you to connect to zoltar. The commands Sys.getenv("Z_USERNAME") and Sys.getenv("Z_PASSWORD") get your username and password from the environment and pass them to zoltar.

The code you pasted is incorrect (plus it shows your account info here publicly, so you should delete your comment). But I like your idea. Instead you should try passing the actual values you pasted above:

devtools::install_github("reichlab/zoltr", force=TRUE)
library(zoltr)
zoltar_connection <- new_connection()
zoltar_authenticate(zoltar_connection, "spxxx", "4Yxxx")

Let us know.

wadspen commented 3 years ago

Oh I see. When I run Sys.getenv("Z_USERNAME") it returns a blank string. But when I just enter my username and password strings directly into zoltar_authenticate(), it looks like the connection is made just fine.


From: Matthew Cornell notifications@github.com Sent: Wednesday, March 10, 2021 3:54 PM To: reichlab/forecast-repository forecast-repository@noreply.github.com Cc: Wadsworth, Spencer G [STAT] sgw96@iastate.edu; Author author@noreply.github.com Subject: Re: [reichlab/forecast-repository] Unable to make connection to Zoltar in R (#291)

Sorry I wasn't clear. The environment variables must be accessible to R in order for you to connect to zoltar. The commands Sys.getenv("Z_USERNAME") and Sys.getenv("Z_PASSWORD") get your username and password from the environment and pass them to zoltar.

The code you pasted is incorrect (plus it shows your account info here publicly, so you should delete yoru comment. But I like your idea. Instead you should try passing the actual values you pasted above:

devtools::install_github("reichlab/zoltr", force=TRUE) library(zoltr) zoltar_connection <- new_connection() zoltar_authenticate(zoltar_connection, "spxxx", "4Yxxx")

Let us know.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/reichlab/forecast-repository/issues/291#issuecomment-796186026, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANBGYLOSLFY4P4UAX2P2PLDTC7MABANCNFSM4YUO5EQQ.

matthewcornell commented 3 years ago

Makes sense. Most people find it convenient (and safer) to use the environment variable feature as mentioned here: http://reichlab.io/zoltr/articles/getting-started.html#setting-up-your-account:

Once you have an account, we recommend storing your Zoltar username and password in your .Renviron file. In practice this means having a file named .Renviron in your home directory. (You can read more about R and environment variables here: https://db.rstudio.com/best-practices/managing-credentials/#use-environment-variables .)

wadspen commented 3 years ago

Great that helped me get things working thanks!

Can I just get your help on downloading a .csv for a forecast from the COVID-19 hub? I'm struggling figuring out how to do that. I'm trying to use the forecast_data_from_cdc_csv_file() function, but I'm not sure what arguments to put in for the forecast I want.

Thanks


From: Matthew Cornell @.> Sent: Wednesday, March 10, 2021 5:14 PM To: reichlab/forecast-repository @.> Cc: Wadsworth, Spencer G [STAT] @.>; Author @.> Subject: Re: [reichlab/forecast-repository] Unable to make connection to Zoltar in R (#291)

Makes sense. Most people find it convenient (and safer) to use the environment variable feature as mentioned here: http://reichlab.io/zoltr/articles/getting-started.html#setting-up-your-account:

Once you have an account, we recommend storing your Zoltar username and password in your .Renviron file. In practice this means having a file named .Renviron in your home directory. (You can read more about R and environment variables here: https://db.rstudio.com/best-practices/managing-credentials/#use-environment-variables .)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/reichlab/forecast-repository/issues/291#issuecomment-796274133, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANBGYLMOLW6AGBWYSUWXIY3TC7VLXANCNFSM4YUO5EQQ.

wadspen commented 3 years ago

Nevermind, I got it working. Thanks!


From: Wadsworth, Spencer G [STAT] @.> Sent: Monday, March 15, 2021 8:22 AM To: reichlab/forecast-repository @.> Subject: Re: [reichlab/forecast-repository] Unable to make connection to Zoltar in R (#291)

Great that helped me get things working thanks!

Can I just get your help on downloading a .csv for a forecast from the COVID-19 hub? I'm struggling figuring out how to do that. I'm trying to use the forecast_data_from_cdc_csv_file() function, but I'm not sure what arguments to put in for the forecast I want.

Thanks


From: Matthew Cornell @.> Sent: Wednesday, March 10, 2021 5:14 PM To: reichlab/forecast-repository @.> Cc: Wadsworth, Spencer G [STAT] @.>; Author @.> Subject: Re: [reichlab/forecast-repository] Unable to make connection to Zoltar in R (#291)

Makes sense. Most people find it convenient (and safer) to use the environment variable feature as mentioned here: http://reichlab.io/zoltr/articles/getting-started.html#setting-up-your-account:

Once you have an account, we recommend storing your Zoltar username and password in your .Renviron file. In practice this means having a file named .Renviron in your home directory. (You can read more about R and environment variables here: https://db.rstudio.com/best-practices/managing-credentials/#use-environment-variables .)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/reichlab/forecast-repository/issues/291#issuecomment-796274133, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANBGYLMOLW6AGBWYSUWXIY3TC7VLXANCNFSM4YUO5EQQ.