Sage-Bionetworks / synapser

An R package providing programmatic access to Synapse
Apache License 2.0
32 stars 21 forks source link

ENH: get API Key #277

Closed muschellij2 closed 4 years ago

muschellij2 commented 4 years ago

Operating system

Max OSX

Description of the problem

Default in synLogin is that no credentials are given. Should add a check that

if (is.null(email) && is.null(password)) {
   if (is.null(apiKey)) {
       apiKey = Sys.getenv("SYNAPSE_API_KEY")
   }
}

so that if you have a SYNAPSE_API_KEY variable set in ~/.Renviron or environment (and using R from the terminal), then it will auto login.

Expected behavior

Login if API set in ~/.Renviron

Actual behavior

Fails if no credentials given

brucehoff commented 4 years ago

Sorry for the late reply. You can store your API key in a .synapseConfig file, as explained in https://r-docs.synapse.org/articles/manageSynapseCredentials.html

muschellij2 commented 4 years ago

I agree, but why not add the functionality for it to check in ~/.Renviron after checking for the config file? I feel as most users add to ~/.Renviron. Otherwise, if that's not the case, what about a function that's like generate_synapse_config(email, username, api_key)?