Migration API : cannot use writeClient on a read-protected repo

Hi,

We are trying out the new Migration API, following the documentation : Migrating to Prismic - Documentation - Prismic

Our repository already exists and is protected (Private Content API). We want to migrate new batches of data using the migration API, but the writeClient fails with an error :

response: { error: 'Invalid access token' }

We temporarily switch our Content API security to Public and it solves the issue.

Digging into the createWriteClient method options, I don't see a way to set a content access token, is it possible to do so ?

Thanks !

Hi @gbelorgey, the write client is an extended version of the normal client. You can provide an access token using the accessToken option when creating a client:

import { createWriteClient } from "@prismicio/client";

const client = createWriteClient("example-prismic-repo", {
  accessToken: "example-access-token",
  writeToken: "example-write-token"
})
1 Like