Bug: Custom Types Tokens Invalidated

Scenario:

  1. Create a custom types token on a dev environment repository
  2. Use the token to make a request to the custom types API
  3. Request succeeds
  4. Sync the dev environment repository
  5. Use the same token to make another request

Expected: Request succeeds again

Actual: Request fails. A new custom types token is required.

Hi Daniel,

I see that this was an issue originally in your Gatsby app. Is this the behaviour you're see when testing in something like Postman?

Thanks.

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

I'm not sure. I only use the Prismic Gatsby plugin to interface with Prismic. I can assure you that this issue is very reproducible however. I am continuing to run into this problem.

Hi Daniel, thank you for contacting us.

  • Could you show me a picture of the error and a timestamp of when it happens again?
  • the environments of your project come from the Prismic Environment feature or your project's setup?

If you have two environments in Prismic, you will have to generate two plugin configurations and two different tokens.

Please make sure you have the Custom Types API feature activated in your repository. You can check by going to your repository's Settings > API & Security. You should see the Custom Type API tab. Let us know if you don't see this tab and we'll activate it for you.

  • Error: image
  • This is triggered with the Prismic Environment Feature

We already are working with the custom types API on our Prismic repo.

I see, and if you run it in development, do you get an error as well?

Is any of your environments private? If they are you need to add an Access token for each private repo.

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

I work with Daniel and have just experienced this issue again today after syncing our dev environment with production. After syncing environments, attempting to develop against the Prismic dev environment with gatsby-plugin-prismic throws the 400 error. Developing against the production Prismic environment still works fine. We have access tokens in place and they don't seem to break after syncing environments.

Generating a new Custom Type API token and using it fixes the issue. However, syncing environments shouldn't break the api token. This causes us to have to update environment variables every time we sync environments.

Hey there @jluttrell, thanks for following the conversation.

The point is that environments should be treated as separate entities. You can see them as 'copies' of your main repository. That is why it will always be necessary to use the token corresponding to each repo, one for testing on development and one for the production site.

Pau, please read my original message again. I realize the tokens are different for dev/prod repos. The point is that syncing the repos invalidates the dev token and we have to generate a new one manually. This is not an acceptable behavior. Is there a timeline to fix this?

Sorry about that, I did not understand in case of using the first time. Maybe it's a problem on our side. First, I would like to know what token you are using. Is it a Permanent token or a User session token?

The user token expires at the same time as the user's session.

It is a permanent token.

Thanks for the information. I was able to reproduce the issue. I'll raise this ticket with the relevant team, and we'll update this same thread when there's any news.

Thanks

Thank you @Pau! @jluttrell and I really appreciate your help on this issue :slight_smile:

1 Like

Of course. And, I'll be sure to keep you posted on this issue.
Please let me know if anything else comes up

2 Likes