Prismic::SearchForm::AuthorizationException

I don't get this error. It appears randomly when I make calls:

Prismic::SearchForm::AuthorizationException:  Prismic::SearchForm::AuthorizationException

I'm using the ruby gem prismic.io | RubyGems.org | your community gem host

My configuration is:

CACHE = Prismic::BasicNullCache.new.freeze
ACCESS_TOKEN = "..."
api = Prismic.api(
  "https://your-repo-name.cdn.prismic.io/api",
  access_token: ACCESS_TOKEN,
  api_cache: CACHE,
  cache: CACHE
)

Hi Mohamed,

My guess is because you are caching the content from Prismic, this isn't recommended as you will get this error and outdated content using old master refs.

Thanks.

Hello Phil,

I don't use caching, that is why I have this line of code CACHE = Prismic::BasicNullCache.new.freeze

I saw that you are mentioning the API v2 (https://your-repo-name.cdn.prismic.io/api/v2),
while I'm mentioning the API v1 (https://your-repo-name.cdn.prismic.io/api).

I change my code to use the API v2:

CACHE = Prismic::BasicNullCache.new.freeze
ACCESS_TOKEN = "..."
api = Prismic.api(
  "https://your-repo-name.cdn.prismic.io/api/v2",
  access_token: ACCESS_TOKEN,
  api_cache: CACHE,
  cache: CACHE
)

But the gem doesn't work with this version of the API.
It's totally broken.

That's correct the ruby gem uses version 1 of the API.

Have you set your repository to private?

How are you passing the master ref?

I found the issue. I was saving the connetion (Prismic.api(...)) inside a variable, like so:

@api ||= Prismic.api(...)

and this @api variable had the wrong ref when we updated documents.

Solution:

@api = Prismic.api(...)
1 Like

Great, I'm glad you were able to figure this issue out. :slight_smile:

1 Like