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
SymbolixAU opened this issue Jul 10, 2019 · 6 comments
Closed

get_access_token to use Sys.getenv() #209

SymbolixAU opened this issue Jul 10, 2019 · 6 comments
Assignees
Labels

Comments

@SymbolixAU
Copy link
Owner

@SymbolixAU 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 self-assigned this Jul 10, 2019
@MichaelChirico
Copy link
Contributor

@MichaelChirico 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
Owner Author

@SymbolixAU 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

@MichaelChirico MichaelChirico commented Jul 10, 2019

I'm dumb & just waking up; edited

@SymbolixAU
Copy link
Owner Author

@SymbolixAU SymbolixAU commented Jul 10, 2019

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

SymbolixAU added a commit that referenced this issue Jul 10, 2019
@SymbolixAU
Copy link
Owner Author

@SymbolixAU SymbolixAU commented Jul 10, 2019

this is what I've gone for

SymbolixAU added a commit that referenced this issue Jul 10, 2019
@SymbolixAU
Copy link
Owner Author

@SymbolixAU SymbolixAU commented Sep 2, 2019

reconsider this based on comments here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.