algolia / docsearch

:blue_book: The easiest way to add search to your documentation.
https://docsearch.algolia.com
MIT License
3.93k stars 381 forks source link

Invalid Application-ID or API key in docusaurus #1261

Closed casionone closed 2 years ago

casionone commented 2 years ago

Description

The staff told me the Api key and other information via email(https://support.algolia.com/hc/en-us/requests/469650) But using in my docusaurus program, the request is always 403 {"message":"Invalid Application-ID or API key","status":403}

The algolia configuration can be found here https://github.com/apache/incubator-linkis-website/blob/dev/docusaurus.config.js This is the website https://linkis.apache.org/

algolia configuration content:

  algolia: {
         // If Algolia did not provide you any appId, use 'BH4D9OD16A'
         appId: 'AE29KQB3IA',
         // Public API key: it is safe to commit it
         apiKey: '45704b29a165163f47127b8d8bbaac6f',
         indexName: 'linkis-apache',
     },

The 403 Request

Request URL: https://ae29kqb3ia-2.algolianet.com/1/indexes/*/queries?x-algolia-agent=Algolia%20for%20JavaScript%20(4.11.0)%3B%20Browser%20(lite)%3B%20docsearch%20(3.0.0-alpha.42)%3B%20docsearch-react%20(3.0.0-alpha.42)%3B%20docusaurus%20(2.0.0-beta.13)&x-algolia-api-key=45704b29a165163f47127b8d8bbaac6f&x-algolia-application-id=AE29KQB3IA
Request Method: POST

Form data

{
    "requests": [
        {
            "indexName": "linkis-apache",
            "params": "attributesToRetrieve=%5B%22hierarchy.lvl0%22%2C%22hierarchy.lvl1%22%2C%22hierarchy.lvl2%22%2C%22hierarchy.lvl3%22%2C%22hierarchy.lvl4%22%2C%22hierarchy.lvl5%22%2C%22hierarchy.lvl6%22%2C%22content%22%2C%22type%22%2C%22url%22%5D&attributesToSnippet=%5B%22hierarchy.lvl1%3A10%22%2C%22hierarchy.lvl2%3A10%22%2C%22hierarchy.lvl3%3A10%22%2C%22hierarchy.lvl4%3A10%22%2C%22hierarchy.lvl5%3A10%22%2C%22hierarchy.lvl6%3A10%22%2C%22content%3A10%22%5D&snippetEllipsisText=%E2%80%A6&highlightPreTag=%3Cmark%3E&highlightPostTag=%3C%2Fmark%3E&hitsPerPage=20&facetFilters=%5B%22language%3Azh-CN%22%2C%5B%22docusaurus_tag%3Adefault%22%2C%22docusaurus_tag%3Adocs-download-current%22%2C%22docusaurus_tag%3Adocs-faq-current%22%2C%22docusaurus_tag%3Adocs-default-current%22%2C%22docusaurus_tag%3Adocs-community-current%22%5D%5D",
            "query": "123"
        }
    ]
}
shortcuts commented 2 years ago

Hey, the request is still sending BH4D9OD16A as an appId on your website, have you upgraded to the latest version of Docusaurus?

casionone commented 2 years ago

Hey, the request is still sending BH4D9OD16A as an appId on your website, have you upgraded to the latest version of Docusaurus?

Just now I tried to remove the appId configuration, and now the appId: AE29KQB3IA is restored. image

Using "docusaurus/core ": "^2.0.0-beta.6".

shortcuts commented 2 years ago

I'd recommend to upgrade to the latest version (beta.9 IIRC) and open an issue on Docusaurus if the error persists

cc @slorber, might be worth checking if it's an update issue or configuration issue

shortcuts commented 2 years ago

(If you try the search in your crawler crawler -> editor -> search preview (right side panel) you can see it working

casionone commented 2 years ago

I'd recommend to upgrade to the latest version (beta.9 IIRC) and open an issue on Docusaurus if the error persists

cc @slorber, might be worth checking if it's an update issue or configuration issue thanks!

I upgrade to the laster version beta.14 ,but still get 403 . I will close the issues and open an issue on Docusaurus

casionone commented 2 years ago

I'd recommend to upgrade to the latest version (beta.9 IIRC) and open an issue on Docusaurus if the error persists

cc @slorber, might be worth checking if it's an update issue or configuration issue

I found that I copied the configuration of other people's projects, the interface call is ok, This configuration is ok

algolia: {
      apiKey: '5f882bef2dfc81f5f1b4e5ea87b2f165',
      indexName: 'apache_shenyu',
      contextualSearch: true,
 },

This configuration is 403

 algolia: {
      appId: 'AE29KQB3IA',
      apiKey: '45704b29a165163f47127b8d8bbaac6f',
      indexName: 'linkis-apache',
  },

It seems that there is a problem with my appid or apikey? But it was sent to me by email, how do I know if the appid/apikey sent to me is correct?

shortcuts commented 2 years ago

Hey,

Sorry for responding too fast, but it seems this API key does not exists. I wonder what caused the issue.

You can use those credentials to make the search work, here's a sandbox and a snippet: https://codesandbox.io/s/sharp-hypatia-8xcxd?file=/src/index.js

  appId: "AE29KQB3IA",
  apiKey: "9ca054a67ee2403605e78587a518b0d6",
  indexName: "linkis-apache"
casionone commented 2 years ago

Hey,

Sorry for responding too fast, but it seems this API key does not exists. I wonder what caused the issue.

You can use those credentials to make the search work, here's a sandbox and a snippet: https://codesandbox.io/s/sharp-hypatia-8xcxd?file=/src/index.js

  appId: "AE29KQB3IA",
  apiKey: "9ca054a67ee2403605e78587a518b0d6",
  indexName: "linkis-apache"

thanks, now it worked