If anybody is strangling with it, the proper solution is to use both wp_set_auth_cookie
specifying the second parameter being the logged_in cookie, which now gives me the following code:
wp_set_current_user($user_id);
if ( wp_validate_auth_cookie( '', 'logged_in' ) != $user_id )
{
wp_set_auth_cookie( $user_id );
}
And to add an action, as suggested in this thread: Extend WordPress (4.x) session and nonce to have the logged-in current cookie properly overriden without needing a page refresh.
That was a tricky one for sure, and undocumented anywhere. Did anybody tried that yet ?
Thanks for your attention anyway,
Related Posts:
- How does nonce verification work?
- Nonce retrieved from the REST API is invalid and different from nonce generated in wp_localize_script
- How to expire a nonce?
- How do I create a user using the new JSON api in 4.7?
- Verify nonce in REST API?
- WordPress REST API call generates nonce twice on every call
- Fatal error: Call to undefined function wp_create_nonce()
- How to add/retrieve the post trash link?
- Using nonce external of WP Admin
- Nonce best practices: hidden input vs. wp_localize_script?
- Reduce nonce lifespan
- Headless WordPress: How to authenticate front end requests?
- “The link you followed has expired” when previewing a post
- wp_verify_nonce keeps failing
- WP REST API: check if user is logged in
- increase nonce lifespan
- Can’t GET draft posts via REST API from headless frontend
- Rest API invalid nonce with Backbone Client
- wp_verify_nonce() via REST always returns false
- Nonce failing in IE
- Full page NGINX (or Cloudflare) caching and WordPress nonces
- WordPress REST API, Expired Nonce from Cache results in 403 forbidden
- my theme breaks WP export
- Why am I getting a 403 from check_admin_referer()?
- Passing a borrowed nonce through Postman fails
- how to send Ajax request in wordpress backend
- permission_callback has no effect
- Identical wp_rest nonce returned from rest_api
- Return WP_Error as WP_REST_Response
- Is there an equivalent to WP_Error object I can return in the case of a successful REST request?
- WP REST API – Nonce passes wp_verify_nonce even after logout
- x-wp-nonce across domains
- wp_create_nonce doesn’t verify when using WP_List_Table
- Are nonces in WP REST API optional by default?
- Handling expired nonces
- What is really “wp_nonce_field” and how does it work? [duplicate]
- Rest API: wp_verify_nonce() fails despite receiving correct nonce value
- Cannot verify nonce
- wp_verify_nonce return false despite correct parameter passed
- WordPress JSON API nonces and Vue development server
- Verify a nonce in Form submission
- Backbone with custom rest endpoints
- phpcs error in WordPress
- Stop WordPress nonces expiring
- Several nonces?
- Nonce for Trashing Item
- Nonce keeps failing
- Public posts – preventing duplicate form submissions
- How to obtain “wp_rest” nonce for WP Statistics plugin manually?
- Log in user using WordPress REST API
- How to verify which WordPress user requested the API in ASP .NET Core?
- WordPress “nonce” message
- wp_nonce vs jwt
- CSP nonces with Cloudflare Workers
- Why are nonces working in Firefox but not in Chrome?
- wp_verfy_nonce keeps giving false
- Nonce – reissue with ajax poll
- wp_nonce_url generating invalid links
- Rest WP_Error always return null
- Register rest field authentication with REST API
- How to insert wp_nonce field within echoed string
- Nonce check causing issues when creating new post
- Weird nonce validation problem
- Logout button in menu without “wp” in links
- Rest API nonce is being cached
- Nonce validation in REST API
- Accessing an auth protected custom WP API enpoint from remote origin
- WooCommerce Order Sync via Custom REST API Endpoint Failing
- Check nonce in the new bulk_edit_posts action
- WP_Error Object in wp_remote_post & wp_remote_get
- nonce de sécurité invalide
- Is the WordPress REST API installed and enabled in a vanilla WordPress 4.7 installation?
- WordPress 4.7.1 REST API still exposing users
- How do you retrieve a post by slug name through REST API?
- wp_verify_nonce vs check_admin_referer
- Does something like is_rest() exist
- Hiding WordPress REST API v2 endpoints from public viewing
- How to: Make JWT-authenticated requests to the WordPress API
- How to use OAuth authentication with REST API via CURL commands?
- WordPress Rest API custom endpoint optional param
- With Rest V2 (WP4.7) how does one restrict certain RESTFUL verbs?
- Using the Rewrite API to Construct a RESTful URL
- WP Rest API: details of latest post including featured media url in one request?
- Do I need a nonce field for every meta box I add to my custom post type admin?
- WP REST API: filter by category 1 AND category 2
- How to do a meta query using REST-API in WordPress 4.7+?
- REST API purpose?
- SSO / authentication integration with external ‘directory service’
- Get post count in wp rest API v2 and get all categories
- Filtering multiple custom fields with WP REST API 2
- WP REST API — How to change HTTP Response status code?
- wp_get_current_user() function not working in Rest API callback function
- Can I use the same nonce for multiple requests on the same page?
- How to use WP-REST API to login user and get user data for Android app?
- How to get a unique nonce for each Ajax request?
- How to get custom post meta using REST API
- Are Nonces Useless?
- Add media with WP-Rest-API v2
- Can I use REST-API on plain permalink format?
- How to remove rest api link: in http headers?