algolia / firestore-algolia-search

Apache License 2.0
112 stars 35 forks source link

Unauthenticated firebase functions? #97

Closed Cosmopal closed 2 years ago

Cosmopal commented 2 years ago

Hi, Currently, I have deployed the algolia-firestore extension along with a transform function as explained in the README. With my current deployment, I get this error:

Error when performing Algolia index { FetchError: invalid json response body at https://accounts.google.com/ServiceLogin?passive=true&continue=https://el.appengine.google.com/_ah/conflogin%3Fstate%3D~< some long key >
reason: Unexpected token < in JSON at position 1

So looks like Algolia app is not properly authenticated before calling the firebase transform function. This results in the app skipping the transform and just writing the firebase doc as it is.

The README Mentions: The Transform Firebase Function should be set up to unauthenticated users at this time

But there doesn't seem to be any option to set https callable functions to be unauthenticated in firebase. Can you please help understand what exactly I need to do for the transformation to work?

Cosmopal commented 2 years ago

I found the issue. I was using a different location for the firebase function that what I had deployed Algolia on.

dejiemiabata commented 2 years ago

hey @Cosmopal I am getting the same error (and I am using the correct location I had deployed Algolia on). Do you mind advising if this is the right logic for creating an algolia transform function ?

export const transformPosts = functions.region("us-central1").https.onCall(async (payload) => { const { userId: userIds } = payload const userId = await localFirestore.collection("users").doc(userIds).get() return { userId } })