Hashan
Hashan

Reputation: 184

Laravel - Nexmo "Please provide Nexmo API credentials" Error

I want send send SMS with laravel-Nexmo. I already configure all the settings. But when i try to send a SMS it gives this error

Please provide Nexmo API credentials. Possible combinations: api_key + api_secret, api_key + signature_secret, private_key + application_id, api_key + api_secret + private_key + application_id, api_key + signature_secret + private_key + application_id

I added nexmo api_key & secret_key in services.php , .env file and nexmo.php I also added this; curl.cainfo="C:\xampp\apache\bin\cacert.pem" in php.ini file

What is the reason for this error and how to fix this? Thank you!

Upvotes: 1

Views: 1183

Answers (3)

Khalil
Khalil

Reputation: 225

I am using Laravel 8 and faced the same issue. Then I realize that I was adding

  NEXMO_KEY=your key here 
  NEXMO_SECRET=your secret here 

to .env.example file. I just added it to .env file and re-config the cache by php artisan config:cache Now it's working.

Note: you should get your api_key and secret rom vonage.com

Upvotes: 0

Aine
Aine

Reputation: 2708

I ran into the same issue, and was able to fix it.

Cause

It looks to me like laravel/nexmo-notification-channel has been updated, but Laravel itself hasn't (yet).

According to the Laravel [6.x] pull request:

composer require laravel/nexmo-notification-channel

This will also install the nexmo/laravel package. This package includes its own configuration file. You can use the NEXMO_KEY and NEXMO_SECRET environment variables to set your Nexmo public and secret key.

https://github.com/laravel/docs/pull/5519/files?short_path=7c04c15#diff-7c04c1591e2821d381785df56ebd70af

Solution It was easy, just copy this new nexmo.php config file into your config folder: https://github.com/Nexmo/nexmo-laravel/blob/master/config/nexmo.php

As long as you have the NEXMO_KEY and NEXMO_SECRET set in your .env file, it should now work.

Upvotes: 0

dragonmantank
dragonmantank

Reputation: 15476

I already configure all the settings.

What exact settings did you configure? The error means that the library could not determine an appropriate set of credentials to use for Nexmo.

If you are sending an SMS, all you need to set is NEXMO_KEY and NEXMO_SECRET. I would try setting just those two environment options and see if you get the same error. If you are using request signing by setting NEXMO_SIGNATURE_SECRET, I would disable that for the time being just to check that sending a base SMS works.

Once you update your settings, I would make sure that the cache is cleared using artisan config:clear to clear the cache, which should allow the settings to be picked up on the next page load.

Upvotes: 1

Related Questions