readline() is magic

I don't really know how to provide a reprex for this but I'm hoping someone can help:

I have this authenticating function that uses a simple shiny app to allow users to enter a username/password without printing it to the console (shamelessly stolen from https://github.com/r-dbi/RPostgres/issues/26#issuecomment-84040230)

authenticating_function <- function() {
  authReqs <- list()
  login = runGadget(loginApp,
                    viewer = dialogViewer("Enter username and password",
                                          width = 400,
                                          height = 400))
  path = login$database_name
  userID = login$username
  password = login$password

  authReqs[[1]] <- list(path=path, userID=userID, pswd=password)
  readline("i am a mystery line that magically makes this function work. enter anything your heart desires")
  return(authReqs)
}

However, none of the httr::POST() queries that use this function work when I comment out the readline() command (it was leftover from the previous method of authenticating which had the console issue). If the readline() is left there - works flawlessly, except that the user now has to type something into the console (not it's not even saved anywhere!). In either case, the output appears exactly the same.

output that is the same in both cases (as far as I can tell):
[[1]]
[[1]]$path
[1] "a_pathname"

[[1]]$userID
[1] "a_username"

[[1]]$pswd
[1] "a_password"

I suppose I left out my question....any ideas why and how to remove the readline() line?
thanks

What is the way in that they don't work?
They error out? They fail silently?

Can you write a non shiny script that has the info in the atheist you require and make the http post calls you want (with and without readline?)

I get the following error, which I understand to be related to the POST call (this part is a bit over my head, clearly)

Error in curl::curl_fetch_memory(url, handle = handle) : 
  Operation was aborted by an application callback

I'm not sure of a great way to provide an example, as I can't provide access to the underlying database. The POST call works fine if I replace the shiny app with more readline()s to obtain the username/password, or if I just hardcode them into the authenticate function.

My best solution right now is to make the readline() say readline("Press any key to continue...")

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.