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
- Check nonce in the new bulk_edit_posts action
- WP_Error Object in wp_remote_post & wp_remote_get
- How to use _embed when using _fields?
- How to return Meta data from the REST API?
- How do WordPress Nonces Work?
- WordPress REST API – Permission Callbacks
- Filter posts by multiple custom taxonomy terms using AND operator in REST API v2 (WordPress)
- WordPress REST API – JSON “Rendered” Content Incorrect
- Extend Woocommerce rest api routes fails
- Attach featured image to custom endpoints
- Recommended way to remove WP REST API returned data for custom post
- Create multiple posts with WP REST API at once
- Prevent wp_insert_user from creating duplicate users
- Develop REST API using WordPress for Android app [closed]
- WordPress Rest API custom endpoint for RSS feed
- Create Media via REST API from Android Application
- Handle new created WP_Error
- how to do login using woocommerce rest api From android
- Why it doesn’t show media urls on rest Api? (WordPress)
- rest_no_route on custom API endpoint wordpress
- Save default options as an array of options and display in REST API
- Images are displaying as blank images
- Replace content via rest api only?
- Change Dashboard URL from wp-admin to wp-admin/index.php
- Unable to edit server side rendered block
- WP_Query: how to search tags in addition to a custom post type?
- Getting 401 unauthenticated error in WP Rest API revisions
- Adding Amchart Interface to WordPress API
- filter rest api post by a acf filed
- REST Request Post including meta/custom fields
- /wp-admin/ – this link showing me “Index of /wp-admin”/ instead of dashboard
- How to update a lot of posts on my WP site with additional content?
- WordPress Application Passwords not authorizing
- Custom REST route fetching posts by slug isn’t working