• Resolved lunacer

    (@lunacer)


    Hi, I’m trying to import some credentials to the snippet but having trouble.
    When I hardcode the credentials inside of base64_encode(), it works fine.
    However, when I save the credentials to the wp_config.php and call it to the file, it responds 401 error.

    The plugin with the API answered me that the issue is not from their plugin.
    So I’m wondering,
    1. Is it safe to hardcode the API key to the snippet?
    2. If not, what could be the solution for security?

    Thanks,

Viewing 1 replies (of 1 total)
  • Plugin Author Mircea Sandu

    (@gripgrip)

    Hi @lunacer,

    You should have no issues loading constants from wp-config in a WPCode Snippet.

    In wp-config.php you should define those as constants:

    define( 'YOUR_API_KEY', 'APIKEYVALUEHERE' );

    And then, inside the WPCode snippet you can access those like this:

    $your_api_key = defined( 'YOUR_API_KEY' ) ? YOUR_API_KEY : '';

    Now you can pass $your_api_key to the logic that you have to connect to the API.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.