-
Notifications
You must be signed in to change notification settings - Fork 800
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 Block: Use the A8C's Mapbox access token if the site doesn't provide one #14307
Conversation
Caution: This PR has changes that must be merged to WordPress.com |
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: February 11, 2020. |
@Copons It's possible we might want to rotate this key at times. What do you think of providing the key through the wpcom API in some way so that we can rotate it when needed without a Jetpack release? |
Copons, Your synced wpcom patch D37418-code has been updated. |
@creativecoder good point. I've created D37434-code and updated this PR accordingly. |
I'm putting this in review, even though I'm not super happy about how it provides the access token to the editor. |
Copons, Your synced wpcom patch D37418-code has been updated. |
Copons, Your synced wpcom patch D37418-code has been updated. |
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.
I'd rather fetch it directly in JS than doing so in PHP and sending the token to JS via wp_localize_script, but it always fails because of the CORS.
Do you think it may be possible to change things at a higher level, and query WordPress.com for an API key here?
public static function get_service_api_key( $request ) { |
In doing so you would be able to reuse the existing elements used to query /wpcom/v2/service-api-keys/mapbox
.
Maybe that would mean adding an extra element to the response returned by get_service_api_key
(in addition to service_api_key
) so that we know that the key returned comes from Automattic and the whole token settings sidebar interface should not be displayed?
Thanks for the review @jeherve!
That was my initial approach, but I found a few blockers and went for the WPCOM endpoint instead. |
Copons, Your synced wpcom patch D37418-code has been updated. |
Copons, Your synced wpcom patch D37418-code has been updated. |
2 similar comments
Copons, Your synced wpcom patch D37418-code has been updated. |
Copons, Your synced wpcom patch D37418-code has been updated. |
9336c14
to
9c25745
Compare
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.
I am merging this for now, this tests well for me.
Quick note that we'll probably need to revisit how we fetch the API key here:
https://github.com/Automattic/jetpack/blob/update/mapbox-access-token/_inc/lib/core-api/wpcom-endpoints/service-api-keys.php#L315
While this works well for public sites, it wont't work for private sites on WordPress.com as we need to be authenticated to make requests to those sites.
We'll consequently probably need to go through wpcom_json_api_request_as_blog
there.
r202027-wpcom |
Because of new sites on WordPress.com being "private by default", we'll need the api key request to be authenticated. Using the map block as part of scaffolding content for new sites (which are private) is a primary reason for this update to the map block. Tracking in #14475 |
* [not verified] Remove empty readme section * Initial changelog for 8.2 * Changelog: add #14220 * Changelog: add #14252 * Changelog: add #14291 * Changelog: add #14309 * Changelog: add #14304 * Changelog: add general connection log. * Changelog: add #14275 * Changelog: add #14313 * Changelog: add #14213 * Changelog: add #14357 * Add sync testing instructions * Add 8.1.1 changelog back See eeaafab and 61757eb * Changelog: add #14371 * Changelog: add #14386 * Changelog: add #14471 * Changelog: add #14325 * Changelog: add #14194 * Changelog: add #14340 * Changelog: add #14418 * Changelog: add #14417 * Changelog: add #14075 * Changelog: add #14467 * Changelog: add #14307 * Changelog: add #14326
Fix https://github.com/Automattic/Dotcom-roadmap/issues/74
As this is a proof of concept, I haven't included the real A8C Mapbox access token yet.
For testing purpose, the
MAPBOX_A8C_ACCESS_TOKEN
constant can be locally updated with the real A8C token (a12s know where to find it), or with a personal one.Changes proposed in this Pull Request:
Is this a new feature or does it add/remove features to an existing part of Jetpack?
Internal reference: pb5gDS-ev-p2
Testing instructions:
Prerequisites
Jetpack
Simple
Atomic
update/mapbox-access-token
feature branch, and activate it.Proposed changelog entry for your changes: