stillmatic/quiltr

login issues

stillmatic opened this issue · 1 comments

in order to login we basically need to reimplement the login() function (https://github.com/quiltdata/quilt/blob/2a5dff59b6ae3616bfe504f9134522579d8e5606/quilt/tools/command.py#L166). we can't reuse the existing code because neither reticulate nor command line via system() accepts input of the access token.

the easiest way to do it is something like this:

qlogin <- function(quilt_url = 'https://pkg.quiltdata.com') {
    # QUILT_PKG_URL = os.environ.get('QUILT_PKG_URL', DEFAULT_QUILT_PKG_URL)
    quilt <- reticulate::import("quilt")
    login_url <- sprintf("%s/login", quilt_url)
    browseURL(login_url)
    refresh_token <- readline("Enter the code from the page: ")
    # hacky stuff follows - names shouldn't start with underscores in R
    auth <- eval(parse(
        text = paste("quilt$tools$command$_update_auth(refresh_token)")))
    eval(parse(
        text = paste("quilt$tools$command$_save_auth(auth)")
    ))
    eval(parse(
        text = paste("quilt$tools$command$_clear_session()")
    ))
}

however, in R, names cannot start with underscores; even though this code will compile, it will not run when we get to the eval step. the unexported auth code is a problem here.

possible workarounds:

  • in Python, implement a login_with_code() method. this would act like login(), but accept the access token as a parameter. this is probably most robust.
  • in R, reimplement the unexported auth functions. I would rather not do this because auth procedures are liable to change, and i'm not entirely sure that we could easily pass the auth tokens between reticulate sessions.

closed in f7c5440