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
- All wp-json routes suddenly return 404
- WordPress – Contact Form 7 – Get uploaded file issue
- Nonce validation in REST API
- API call from searchbar in wordpress
- Looking for a working code example in python for creating a post
- Transmit headers and footers via API from one site to another
- Accessing an auth protected custom WP API enpoint from remote origin
- WordPress Error uploading image: 401 API Python Script
- Is the WordPress REST API installed and enabled in a vanilla WordPress 4.7 installation?
- Does something like is_rest() exist
- How to: Make JWT-authenticated requests to the WordPress API
- WordPress Rest API custom endpoint optional param
- Using the Rewrite API to Construct a RESTful URL
- REST API purpose?
- Get post count in wp rest API v2 and get all categories
- WP REST API — How to change HTTP Response status code?
- wp_get_current_user() function not working in Rest API callback function
- How to use WP-REST API to login user and get user data for Android app?
- Nonce retrieved from the REST API is invalid and different from nonce generated in wp_localize_script
- WP REST API Is it rather easy to rename the default wp-json uri part?
- Query WP REST API v2 by multiple meta keys
- Search WP API using the post title
- check the requesting url
- How would I add custom tables/endpoints to the WP REST API?
- WP REST API Require Password for GET Endpoint
- Displaying a page built with Elementor using the REST API [closed]
- Getting user meta data from WP REST API
- How do I cache (core) API requests?
- WP REST API only returning partial list of users
- Fetch All Posts (Including Those Using a Custom Post Type) With WordPress API
- WP REST API no longer supports filter param, so how do I get posts in a custom taxonomy?
- Understanding SHORTINIT with WordPress 5
- Is there a way to get protected meta fields through any of the available built-in WordPress APIs? (xmlrpc, wp-json)
- How to use _embed when using _fields?
- How does REST API cookie authentication work in WP 4.7?
- WP REST API V2 – Retrieve sub page by full slug (URL/Path)
- WP REST API create post authentication issue
- Slow REST API calls on self-hosted WordPress [closed]
- How do I create a user using the new JSON api in 4.7?
- Verify nonce in REST API?
- Why is my custom API endpoint not working?
- Is it safe to fix Access-Control-Allow-Origin (CORS origin) errors with a php header directive?
- WordPress REST API validation
- Are there server performance benefits to fetching only specific fields when querying the REST API?
- Retrieving pages with multiple tags using REST API
- How to define a query parameter with REST API?
- Filter posts by multiple custom taxonomy terms using AND operator in REST API v2 (WordPress)
- WP REST API returns blank response if post is too long
- How do I correctly setup an AJAX nonce for WordPress REST API?
- how to authenticate for the REST API from a plugin and from command line
- Why is per_page not working with categories in WP API?
- Increase per_page limit in REST API