Preview token expired errors

I'm getting the following result from the API when an expired token is used. Here is the result.

{
  "type":"api_notfound_error",
  "message":"https://[REDACTED].prismic.io/previews/[REDACTED]?websitePreviewId=[REDACTED] not found"
}

I've had an error handler that looks for "This preview token has expired" that had been working, has the API changed?

Hey!

The API hasn't changed and yes, this happens when the token expires. This can happen if the Prismic toolbar is not setup properly because its role is to update the preview token after a change has been made.

  • Have you tried refreshing the page?
  • Which technology are you using in your project and how did you configured the previews in it?

I'm using .NET.

I maintain the kit for this so I am keen to know if the error type api_notfound_error is only returned for expired preview tokens, or if it would be returned for any badly configured API.

I've seen this occur when a user closes the preview tab without exiting preview mode and the preview is subsequently published. Because the exception is thrown server-side there is no way for the toolbar to tidy up the cookie.

I would like to update the kit to catch the exception and use a piece of middleware to remove the cookie and reload the page.

I see, thanks for the information, I've asked the team. I'll get back to you as soon as I have an answer

Thanks

Hello, I've discussed this with the team today and we've agreed to add it to the issue tracker. Also, if you would like to do a collaboration to make it quicker you can submit a PR to the kit and we'll review it as soon as we can.

Thanks

This issue has been closed due to inactivity. Flag to reopen.

@benembery I've reopened this for you now.

This issue has been closed due to inactivity. Flag to reopen.

@benembery I'm just quoting you here to see if I can get more info for you.

Which api response are you describing?

The CSharp Kit sets the ref set based on the preview cookie, if the cookie is expired they the request throws an exception.

This exception has changed.

{
  "type":"api_security_error",
  "message":"This preview token has expired",
  "oauth_initiate":"https://[REDACTED].prismic.io/auth",
  "oauth_token":"https://[REDACTED].prismic.io/auth/token"
}

I should be able handle it correctly if this is the correct response.