dougB
dougB

Reputation: 509

Getting MaxMind\Exception\AuthenticationException: "your account ID or license key could not be authenticated" when using the sandbox

I have an account with MaxMind anti-fraud service and am using their PHP library which I installed via Composer. I set up a sandbox account and generated a user and license key. However, when following their documentation at https://dev.maxmind.com/minfraud/sandbox-environment I keep getting this message from my unit test after running $client->score(): MaxMind\Exception\AuthenticationException: Your account ID or license key could not be authenticated.

I was expecting to receve a "score" response but instead got the Exception. I did a var_dump() of the MaxMind MinFraud instance and the ID and license key show up clearly and are the same as in the Sandbox admin portal. I regenerated the license key, but got the same results.

Upvotes: 0

Views: 188

Answers (1)

dougB
dougB

Reputation: 509

I posted the question above to document this problem. In the MaxMind API documentation they failed to mention that when creating the MinFraud instance there's a third argument, which is an array of options. Have a look at the class MaxMind\MinFraud\ServiceClient::__construct() and you'll see what I mean. The solution to the problem above is to do this when creating the MinFraud instance:

$id         = YOUR_ID;
$licenseKey = SANDBOX_LICENSE_KEY;
$options    = ['host' =>'sandbox.maxmind.com'];
$client     = new MinFraud($id, $licenseKey, $options);

Upvotes: 1

Related Questions