Opened 6 years ago
Closed 6 years ago
#40422 closed enhancement (fixed)
REST API JavaScript Client: refresh nonce when a new nonce is available
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.9 | Priority: | normal |
Severity: | normal | Version: | 4.7 |
Component: | REST API | Keywords: | has-patch commit |
Focuses: | javascript | Cc: |
Description
Since [37905] the REST API returns a fresh wp_rest
nonce in the headers of (authenticated) requests. The JavaScript client uses nonces for (cookie based) authenticated requests and should keep its internal nonce up to date with the returned nonce. This will be especially useful for long-running JavaScript applications that need to make authenticated requests.
Attachments (3)
Change History (18)
#2
follow-up:
↓ 4
@
6 years ago
This is useful if you're sending API endpoint requests constantly, but not if you just leave the tab open in the background, which still needs heartbeat.
(Also, your patch still has a console.log call in it. :) )
#3
@
6 years ago
- Milestone changed from Awaiting Review to 4.8
in 40422.2.diff removed the console log.
#4
in reply to:
↑ 2
@
6 years ago
Replying to rmccue:
This is useful if you're sending API endpoint requests constantly, but not if you just leave the tab open in the background, which still needs heartbeat.
Right, it is up the developer to decide to poll the API, this just picks up the refreshed nonce if available.
(Also, your patch still has a console.log call in it. :) )
removed :)
This ticket was mentioned in Slack in #core by obenland. View the logs.
6 years ago
#9
@
6 years ago
- Keywords has-patch needs-testing added; needs-patch removed
- Owner set to adamsilverstein
- Status changed from new to assigned
This should be good to go early in 4.9, could use some additional testing for validation.
In 40422.diff :