{"action":"created","issue":{"url":"https://api.github.com/repos/kadamwhite/wordpress-rest-api/issues/104","labels_url":"https://api.github.com/repos/kadamwhite/wordpress-rest-api/issues/104/labels{/name}","comments_url":"https://api.github.com/repos/kadamwhite/wordpress-rest-api/issues/104/comments","events_url":"https://api.github.com/repos/kadamwhite/wordpress-rest-api/issues/104/events","html_url":"https://github.com/kadamwhite/wordpress-rest-api/pull/104","id":98601102,"number":104,"title":"Enable Cookie auth with requests","user":{"login":"gerhardsletten","id":63344,"avatar_url":"https://avatars.githubusercontent.com/u/63344?v=3","gravatar_id":"","url":"https://api.github.com/users/gerhardsletten","html_url":"https://github.com/gerhardsletten","followers_url":"https://api.github.com/users/gerhardsletten/followers","following_url":"https://api.github.com/users/gerhardsletten/following{/other_user}","gists_url":"https://api.github.com/users/gerhardsletten/gists{/gist_id}","starred_url":"https://api.github.com/users/gerhardsletten/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gerhardsletten/subscriptions","organizations_url":"https://api.github.com/users/gerhardsletten/orgs","repos_url":"https://api.github.com/users/gerhardsletten/repos","events_url":"https://api.github.com/users/gerhardsletten/events{/privacy}","received_events_url":"https://api.github.com/users/gerhardsletten/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-02T10:48:15Z","updated_at":"2015-08-05T16:05:48Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/kadamwhite/wordpress-rest-api/pulls/104","html_url":"https://github.com/kadamwhite/wordpress-rest-api/pull/104","diff_url":"https://github.com/kadamwhite/wordpress-rest-api/pull/104.diff","patch_url":"https://github.com/kadamwhite/wordpress-rest-api/pull/104.patch"},"body":"Added possibility to use Cookie Auth when consuming the rest services in client scripts on the same site.\r\n\r\nLocalize your scripts with an object with root-url and nonce:\r\n\r\n```\r\nfunction my_enqueue_scripts() {\r\n    wp_enqueue_script( 'app', get_template_directory_uri() . '/assets/dist/bundle.js', array(), false, true );\r\n    wp_localize_script( 'app', 'WP_API_Settings', array(\r\n        'root' => esc_url_raw( get_json_url() ), \r\n        'nonce' => wp_create_nonce( 'wp_json' ) ) \r\n    );\r\n}\r\nadd_action( 'wp_enqueue_scripts', 'my_enqueue_scripts' );\r\n```\r\n\r\nAnd use this nonce when initialising the library:\r\n\r\n```\r\nvar WP = require( 'wordpress-rest-api' );\r\nvar wp = new WP({\r\n    endpoint: window.WP_API_Settings.root, \r\n    nonce : window.WP_API_Settings.nonce\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/kadamwhite/wordpress-rest-api/issues/comments/128051629","html_url":"https://github.com/kadamwhite/wordpress-rest-api/pull/104#issuecomment-128051629","issue_url":"https://api.github.com/repos/kadamwhite/wordpress-rest-api/issues/104","id":128051629,"user":{"login":"kadamwhite","id":442115,"avatar_url":"https://avatars.githubusercontent.com/u/442115?v=3","gravatar_id":"","url":"https://api.github.com/users/kadamwhite","html_url":"https://github.com/kadamwhite","followers_url":"https://api.github.com/users/kadamwhite/followers","following_url":"https://api.github.com/users/kadamwhite/following{/other_user}","gists_url":"https://api.github.com/users/kadamwhite/gists{/gist_id}","starred_url":"https://api.github.com/users/kadamwhite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kadamwhite/subscriptions","organizations_url":"https://api.github.com/users/kadamwhite/orgs","repos_url":"https://api.github.com/users/kadamwhite/repos","events_url":"https://api.github.com/users/kadamwhite/events{/privacy}","received_events_url":"https://api.github.com/users/kadamwhite/received_events","type":"User","site_admin":false},"created_at":"2015-08-05T16:05:48Z","updated_at":"2015-08-05T16:05:48Z","body":"Thanks for this! Would you be able to add a unit test to verify that the correct property gets set on the response, and validate that the tests pass once you've done so? If not I can tackle that later this week."}}