mapboxapi icon indicating copy to clipboard operation
mapboxapi copied to clipboard

generic 'get access token' function

Open dcooley opened this issue 5 years ago • 3 comments

I see here, for example, you look for Sys.getenv("MAPBOX_SECRET_TOKEN"). Would you consider something a bit more generic that looks for any string with "mapbox" in the environment?

Similar to what I have in mapdeck here

e <- Sys.getenv()
e <- e[ grep( "mapbox|mapdeck", names( e ), ignore.case = TRUE ) ]

(and the related thread)

dcooley avatar Sep 28 '20 22:09 dcooley

yes I like this a lot. The one thing I need to think through is how to handle the distinction between public tokens and secret tokens, as some tasks (e.g. uploading tilesets) require tokens with secret scope, whereas most others do not. When mb_access_token() saves the token to a user's .Renviron, it detects whether or not the token is secret and names it appropriately. I'd like to have more interoperability with other Mapbox packages though which is what your suggestion would achieve.

walkerke avatar Oct 05 '20 11:10 walkerke

yeah good point, I hadn't considered the secret vs public tokens. But interoperability is certainly the goal where the same token can be set once and called by multiple packages.

dcooley avatar Oct 05 '20 20:10 dcooley

100% agree about interoperability - that's one of my priorities as I build out this package more.

walkerke avatar Oct 06 '20 04:10 walkerke