For remote apps (cURL, Postman, etc.), or when not using the browser, you should use an authentication plugin like Application Passwords instead of sending the cookies.
But if you’d rather send the cookies, then copy and send the WordPress logged-in cookie named wordpress_logged_in_<hash>
. Example in cURL:
curl -H "X-WP-Nonce: <nonce>" -X POST https://example.com/wp-json/wp/v2/posts -d "Data here" -b wordpress_logged_in_<hash>=<cookie value>
Note that WordPress saves the user’s login data (username and hashed data) in a cookie named wordpress_logged_in_<hash>
(but you can change it using the LOGGED_IN_COOKIE
constant).
Also, in the above (cURL) example, I used the X-WP-Nonce
header to send the cookie nonce.
UPDATE: Added a screenshot for (locating and copying) the cookie in Chrome:
Related Posts:
- Can’t GET draft posts via REST API from headless frontend
- Log in user using WordPress REST API
- Headless WordPress: How to authenticate front end requests?
- WP REST API: check if user is logged in
- x-wp-nonce is not allowed by Access-Control-Allow-Headers in preflight response
- WordPress REST API “rest_authentication_errors” doesn’t work external queries?
- Full page NGINX (or Cloudflare) caching and WordPress nonces
- WordPress REST API, Expired Nonce from Cache results in 403 forbidden
- How send get request to external api with username and password
- WP_REMOTE_POST Requests are being blocked by API provider [closed]
- permission_callback has no effect
- Get all PDF files from page with WordPress API
- WP REST API – Nonce passes wp_verify_nonce even after logout
- “No Access-Control-Allow-Origin header is present” even though it is in the entry file
- Validate rest-api call on create
- Rest API: wp_verify_nonce() fails despite receiving correct nonce value
- Get a remote post ID via API given URL
- How to change the date and time in REST API for comments?
- Backbone with custom rest endpoints
- WordPress HTTP API NTLM Authentication
- [Zapier + WP Webhooks Pro]: Custom Fields get cut off at first comma or semicolon
- REST API and filtering by meta value
- Rest API: trouble receiving response through script (browser and Postman display correctly)
- Is there a way I can fetch the WordPress Developer Code References with an API?
- How to display relations via wordpress Rest API
- How to add Relations of a CCT from JetEngine via WordPress Rest API
- How to verify which WordPress user requested the API in ASP .NET Core?
- Can I overwrite default WordPress Json API For no more pages text
- trigger WordPress rest any API call
- Secure WordPress API, how?
- wp_nonce vs jwt
- register/login api
- WordPress REST API in Integromat: How to overcome “Sorry, you are not allowed to list users / edit this…”
- how to create JSON array [] for REST response?
- Remove unwanted fields from WP API response
- How to receive JSON payload from a digital device
- The REST API encountered an error in wordpress?
- WordPress API “code”:”rest_no_route” with Custom Route
- Connecting WordPress with an External API
- WordPress single page website redirect to index.html
- Autotrader API Integration
- REST API get featured image source for custom post type
- Register rest field authentication with REST API
- Update post / page using API + python
- JS WordPress API fetch no response headers
- Issue with API after 6.2 update
- Woocommerce API for calling products by Category ID
- Rest API nonce is being cached
- How to use WP-REST API to login user and get user data for Android app?
- How do I cache (core) API requests?
- WP REST API returns blank response if post is too long
- How to feed a HTML5’s EventSource with a REST API custom endpoint?
- Retrieve CSS and JS From the REST API
- How to Authenticate WP REST API with JWT Authentication using Fetch API
- WordPress 4.7 REST API endpoints
- REST API multiple media upload
- 401 Error when trying to make a REST API call to site
- Developing Themes with React/Angular
- Can we access the REST request parameters from within the permission_callback to enforce a 401 by returning false?
- Upload image to wordpress using REST API
- Can I define multiple callback methods depending on the call method?
- Filter post content in REST API
- Create post with REST API in php with file_get_contents
- How add meta fields to a user with the wp-api?
- WordPress Rest API response
- WP Rest API not working
- How do you format the set_body option for WP_Rest_Request?
- featured image not found in json from wp rest api
- is it possible to filter a rest api endpoint by using a registered rest field?
- rendering view in backbone
- Update a post based on results from GET request to another server
- Manipulating/view postmeta remotely
- Check authentication credentials using WP REST API
- WordPress REST API V2: how to get list of all posts?
- Getting 401 from ajax using an application password
- How to connect android app with WordPress website?
- WordPress REST API calls that depend on the WordPress User
- How to get data from /wp-json/wp/v2/users/me
- I can’t post comment via REST API
- WordPress REST API parameters are not affecting a response
- Update meta_value in wp_postmeta using API
- Multisite WP-API json v2 : can i fetch all comments on all sites with a single query?
- wp_signon returns user but the user is not logged in because wp installed on subdomain. How to make it work?
- WordPress plugin with CORS
- “Error: cURL error 60: SSL certificate problem: certificate has expired” when create product in WooCommerce via REST API
- How to use WordPress REST api to login a user?
- Wrong encoding of dynamic block properties problem when loggen in as editor
- Need wp rest api for featured video post
- WordPress output data to another website and pull data
- Set logged in user based on API response
- REST api header link href
- WordPress & React Native
- update meta data (like view counter) by rest-api
- Rest API hook ‘rest_insert_post’ not returning request object
- How to display parent category with first level child in REST API
- How Can I keep password protected posts in the json requests but not on frontend queries?
- Rest API User Levels
- Script tag in string in wordpress rest api body to create post
- Customizer Changeset, Sidebar and Rest API Custom Endpoints
- Uploading media to wordpress API with C# HttpClient