-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
map-specific access token #8364
Conversation
test/unit/ui/map.test.js
Outdated
@@ -50,6 +50,19 @@ test('Map', (t) => { | |||
t.end(); | |||
}); | |||
|
|||
// t.test('map-specific token', (t) => {\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can we instantiate a map with a bad token?
Would like to add a test for the positive case, where it starts with mapboxgl.accessToken = badtoken
but gets overwritten by a valid token inside the map options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can we instantiate a map with a bad token?
The unit tests don't exercise any access token specific logic.
Map options are set-only with no ability to read back to options that were used to instantiate a map object. Since the access token is passed through to the RequestManager
unit tests are probably suited to the behavior of that class.
test/unit/ui/map.test.js
Outdated
@@ -50,6 +50,19 @@ test('Map', (t) => { | |||
t.end(); | |||
}); | |||
|
|||
// t.test('map-specific token', (t) => {\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can we instantiate a map with a bad token?
The unit tests don't exercise any access token specific logic.
Map options are set-only with no ability to read back to options that were used to instantiate a map object. Since the access token is passed through to the RequestManager
unit tests are probably suited to the behavior of that class.
bit stumped by the no-unused-vars lint error -- the flagged variable is used at https://github.com/mapbox/mapbox-gl-js/pull/8364/files#diff-3bdcadb35be47763a1abccc9707d22e0R375 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ryanhamley @peterqliu IS there a reason to separate the implementation of the normalize...URL
methods from the RequestManager
? This PR would be a lot simpler if those were flattened, and all access to a token was through a RequestManager#accessToken()
method.
src/index.js
Outdated
@@ -70,6 +70,7 @@ const exported = { | |||
}, | |||
|
|||
set baseApiUrl(url: string) { | |||
console.log('setting'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log
@asheemmamoowala I'm not sure I follow. the |
Why do the methods need to exist outside the
The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one instance of config.ACCESS_TOKEN
in src/ui/attribution_control.js
that needs to be updated to reference the map-specific access token as well.
Ohhh I get what you're saying @asheemmamoowala. Yes, they could be moved into the |
sounds like something we could tackle in a future PR 👍 @asheemmamoowala @ryanhamley do you see any other blockers to this one? |
Agreed that we can refactor in a separate PR Did you see Asheem's comment above @peterqliu?
|
👍 done ^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 🎉
Launch Checklist
solves #6331
Adds an
accessToken
parameter to Map options, that optionally overwrites the token specified in mapboxgl.accessToken for just that map.