• bdbowles

    (@bdbowles)


    The plugin shows two error toasts after I enter my keys. The keys were copied directly from Algolia so I know they are correct. I have also tried making a new Algolia application in my account, and made an application in a new account, and have had the same problem every time.

    I’m using WP Search with Algolia Version 2.11.3, WordPress version 6.9.4, and PHP version 8.4.11 on a Windows Server.

    The error toasts’ text:
    Impossible to connect, please check your Algolia Application Id.
    We were unable to authenticate you against the Algolia servers with the provided information. Please ensure that you used a valid Application ID and Admin API key.

    I saw that someone else had the same issue three years ago, but never followed up publicly. Any help would be very much appreciated.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    What are the restrictions shown when visiting https://dashboard.algolia.com/account/api-keys/restricted?applicationId=YOURAPPLICATIONHERE ?

    Fill in the actual application ID for that URL. We’re wanting specifically the “Search-only API Key”

    Thread Starter bdbowles

    (@bdbowles)

    Thank you for your prompt reply.

    For the search API key the restrictions are: search, listIndexes, settings & browse.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Hmm.

    Part of the validation process occurs in https://github.com/WebDevStudios/wp-search-with-algolia/blob/2.11.3/includes/class-algolia-api.php#L195-L244

    4 spots that it maybe returns false.

    1. Error with fetching the key as a whole, with an AlgoliaException
    2. “search” scope is NOT set.
    3. The key has more permissions than we allow (the four you listed, and recently added browse with one of our latest releases)
    4. If the key has unlimited TTL (we don’t want unlimited).

    Based on the original error message, we’re hittting the first one, for some reason.

    Have you done any customization to configurations? Specifically items that would be set in https://github.com/WebDevStudios/wp-search-with-algolia/blob/2.11.3/includes/factories/class-algolia-search-client-factory.php like secured keys?

    Thread Starter bdbowles

    (@bdbowles)

    No, I don’t believe there are any customization to configurations. I just put error logs between the last conditional and the last return statement of that file and it accurately logged my app ID and my API Key when I attempted to save changes. Perhaps I’m missing a better way to verify.

    For clarity, after the conditional block starting with if (!empty($custom_config) && is_array($custom_config)) and before the final return statement in the file I put:

    error_log('Creating Algolia Search Client with App ID: ' . $app_id);
    error_log('Creating Algolia Search Client with API Key: ' . $api_key);


    Thread Starter bdbowles

    (@bdbowles)

    Also, just to give you as much info as possible, I noticed that my Admin API Key is not listed under “All API Keys”, which seemed odd to me. Is this expected?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Did anything get logged for that?

    Regarding “All API Keys” listing, I assume this to be expected, but we have zero control with what shows there. That’s an Algolia.com question.

    Out of extra curiosity, have you reached out to Algolia support regarding this? They may be able to help deduce why the app/api pairings aren’t validating, or at least if they SHOULD.

    I still believe we’re likely failing at a spot with this:

    try {
    $acl = $client->getApiKey( $search_api_key );
    } catch ( AlgoliaException $e ) {
    return false;
    }

    Which is a step that includes their PHP SDK

    Thread Starter bdbowles

    (@bdbowles)

    It’s failing in the code below, in class-algolia-admin-page-settings.php. I can do a curl request with the admin API key and App ID and get results. I’ll contact Algolia. I really appreciate your help in narrowing down the issue.

    try {		
    Algolia_API::assert_valid_credentials($settings->get_application_id(), $value);
    } catch (Exception $exception) {
    $valid_credentials = false;
    add_settings_error(
    $this->option_group,
    'login_exception',
    $exception->getMessage()
    );
    }
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Definitely both on the same right paths. The try/catch I pointed out earlier is part of the Algolia_API::assert_valid_credentials() call. Just different spots in the stack trace πŸ˜€

    Thread Starter bdbowles

    (@bdbowles)

    I figured as much. I’ll let you know what Algolia says. Thanks again for all your help.

    Thread Starter bdbowles

    (@bdbowles)

    @tw2113, can you please provide the Algolia PHP SDK version the plugin is using? I am talking to a rep from Algolia and they needed it for troubleshooting.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    @bdbowles we currently ship with "algolia/algoliasearch-client-php": "3.4.2" from Composer.

Viewing 11 replies - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.