Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_access_token to use Sys.getenv() #209

Closed
1 task done
SymbolixAU opened this issue Jul 10, 2019 · 6 comments
Closed
1 task done

get_access_token to use Sys.getenv() #209

SymbolixAU opened this issue Jul 10, 2019 · 6 comments
Labels
enhancement New feature or request

Comments

@SymbolixAU
Copy link
Collaborator

SymbolixAU commented Jul 10, 2019

As well as set_token(), if the user has an environment variable set, get_access_token() should (could) also look for it

Something like

get_access_token <- function(api = "mapbox") {
  api <- getOption("mapdeck")[['mapdeck']][[api]]
  if(is.null(api) ) api <- Sys.getenv("MAPBOX_TOKEN")
  if(is.null(api) ) api <- Sys.getenv("MAPBOX_KEY")
  if(is.null(api) ) api <- Sys.getenv("MAPBOX_API_KEY")
  if(is.null(api) ) api <- Sys.getenv("MAPBOX_API_TOKEN")
  if(is.null(api) ) api <- Sys.getenv("MAPBOX")
  return(api)
}

TODO

  • update docs & articles
@SymbolixAU SymbolixAU added the enhancement New feature or request label Jul 10, 2019
@SymbolixAU SymbolixAU self-assigned this Jul 10, 2019
@MichaelChirico
Copy link
Contributor

MichaelChirico commented Jul 10, 2019

perfect chance for a switch() statement

NVM. just use sys.getenv() takes a vector and then which(!nzchar())

@SymbolixAU
Copy link
Collaborator Author

SymbolixAU commented Jul 10, 2019

@MichaelChirico what would be the input to the switch?

(I see this more as a 'dumb' search for a token)

@MichaelChirico
Copy link
Contributor

I'm dumb & just waking up; edited

@SymbolixAU
Copy link
Collaborator Author

good to know Sys.getenv() takes a vector though!

@SymbolixAU
Copy link
Collaborator Author

this is what I've gone for

SymbolixAU pushed a commit that referenced this issue Jul 10, 2019
@SymbolixAU
Copy link
Collaborator Author

reconsider this based on comments here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant