I'm trying to connect an Ember app to a REST API generated by WordPress. The API requires a nonce value passed along in the header with the request to help prevent CSRF attacks. The nonce value is usually provided in a global javascript variable before the app is loaded. (The process is described well in the REST API documentation) This works fine with the default REST API client that is shipped with the WordPress plugin, for example (written with Backbone).
I'm loading Ember from a PHP template and using a WordPress function to generate the root API URL and nonce. The JavaScript object looks something like this:
var wpApiSettings = {"root":"http:\/\/apisite.dev\/wp-json\/","versionString":"wp\/v2\/","nonce":"3d00cd1c5c"};
The question is, how to I get that nonce into Ember so I can make an authenticated API request?
Aucun commentaire:
Enregistrer un commentaire