Coder Social home page Coder Social logo

Comments (4)

Haroenv avatar Haroenv commented on September 27, 2024

Is the indexName everywhere profiles? does algoliasearchkey have access to that index as well? Does it work if you use a different api key?

from vue-instantsearch.

tom43983 avatar tom43983 commented on September 27, 2024

Thanks, so "profiles" is the index name everywhere. algoliasearchkey is only the API key value. It works when I use a dashboard generated API key. Otherwise the way I generate the key for each user is through a cloud function in Firebase. This is how I do it in my cloud functions:

//generate a key for each new signed-up user, then add it to the user document
const algoliasearch = require('algoliasearch');
const client = algoliasearch('xxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
const index = client.initIndex('profiles');

exports.generateAndAddAlgoliaApiKeyToUser = functions.firestore
  .document('users/{user}')
  .onCreate((snap, context) => {
    console.error("On Create triggered")



    const userid = snap.id

    console.log('the id of the new user id : ' + userid)

    const publicKey = client.generateSecuredApiKey(
      'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', // A search key that you keep private
      {
        filters: `owninguser:${userid}`
      }
    );

    console.log("this is the new key: " + publicKey)



    db.doc('users/' + snap.id).update({
      algoliasearchkey: publicKey,
    });

I realise I don't use the index variable in the function. Is this what causes the key not to work?

from vue-instantsearch.

tom43983 avatar tom43983 commented on September 27, 2024

https://www.algolia.com/doc/api-reference/api-methods/generate-secured-api-key/

This is the guide I used to create the key generation function. I don't see any obligation to specify an index. I just restrict the search for each user with a filter.

from vue-instantsearch.

Haroenv avatar Haroenv commented on September 27, 2024

No, this all should work. As it's a question unrelated to InstantSearch as far as I can tell, I suggest you contact [email protected] describing your issue. I don't know what the cause could be, sorry!

from vue-instantsearch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.