mohamed
(Mohamed Ziata)
March 15, 2022, 10:20am
1
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
)
Phil
(Phil Snow)
March 15, 2022, 12:26pm
2
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.
Hey Dmitry,
Yes, we don’t recommend using a caching system as this can cause issues when the master ref is changed on every document update, this can cause websites to break.
Make sure you are using your CDN endpoint to offer your website extra protection and speed, for example https://your-repo-name.cdn.prismic.io/api/v2 .
Also like Paulina said the platform is very stable. We have exceeded the Uptime of 99.9% for the past 26 consecutive months and are committed to maintaining this standard.
Thanks.
mohamed
(Mohamed Ziata)
March 15, 2022, 1:54pm
4
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.
Phil
(Phil Snow)
March 15, 2022, 3:38pm
5
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?
mohamed
(Mohamed Ziata)
March 16, 2022, 9:10am
6
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
Phil
(Phil Snow)
March 16, 2022, 11:00am
7
Great, I'm glad you were able to figure this issue out.
1 Like