Closed vineet253 closed 1 year ago
The error indicates we couldn't find a compatible set of credentials, which could mean we aren't reading the ENV settings correctly. We did push a change back near the end of October, but that shouldn't have affected anything outside of pubkey authentication.
nexmo/laravel
you are using?Hi there! I'm getting the same error.
I installed laravel/nexmo-notification-channel which installs nexmo/laravel as far as I know. Then I did a vendor publish and this is what my config/nexmo.php looks like:
<?php
return [
...
'api_key' => function_exists('env') ? env('NEXMO_KEY', '') : '',
'api_secret' => function_exists('env') ? env('NEXMO_SECRET', '') : '',
...
'signature_secret' => function_exists('env') ? env('NEXMO_SIGNATURE_SECRET', '') : '',
...
];
Then in my .env file I set:
NEXMO_KEY=[my api key] NEXMO_SECRET=[my_api_secret] NEXMO_SIGNATURE_SECRET=[my signature secret]
I then try to dispatch an SMS with the following code:
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\NexmoMessage;
class ShiftOneHourSMSNotification extends Notification
{
use Queueable;
public $content;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($content)
{
$this->content = $content;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['nexmo'];
}
/**
* Get the Nexmo / SMS representation of the notification.
*
* @param mixed $notifiable
* @return NexmoMessage
*/
public function toNexmo($notifiable)
{
return (new NexmoMessage)
->content($this->content);
}
}
and I reroute the SMS in my user file with the following:
public function routeNotificationForNexmo()
{
return 'hard coded phone number (for now)';
}
But I still get this error:
"message": "Provide either nexmo.api_secret or nexmo.signature_secret"
Any idea what I'm doing wrong? I am on a test account, and I'm not sure if I need to upgrade before being able to use?
@cverster What version of Laravel are you using? The above code looks correct, and as long as the .env
file is updated everything should just flow through (I had almost exactly the same code for a demo at LaraconEU earlier this week, so your code should be good). Some older versions required some additional setup above and beyond just publishing the config.
I'm using Laravel 7. I actually solved this by using the Nexmo\Laravel\Facade\Nexmo facade. It seems that there was an issue with Illuminate\Notifications\Messages\NexmoMessage in that it didn't pick up my named api_secret and signature_secret in the .env file. Anyway, here is the post where I learned to use this: https://laracasts.com/discuss/channels/code-review/nexmo-not-picking-up-credentials-in-env-file
I did some more digging on this, as the Notification channel should use whatever auth we set up. If we support an auth set, so does Notification channel. The Laracast link has you set up only Key + Secret auth, so the issue goes away.
The underlying issue is we don't currently support Key + Secret at the same time as Key + Signature. That is actually a bug with the base SDK, because then that means you cannot use various combinations of APIs together (SMS with signatures and Accounts with key+secret, or SMS with signatures and the Voice API which uses keypair, for example).
I'm going to leave this open until we get the underlying bug fixed.
Thanks for following up! I'll check when a fix arrives so that I can include Secret auth!
@cverster This change is being picked up in the new Vonage namespace for this library that is being actively maintained at https://github.com/Vonage/vonage-php-sdk-core
This package is officially abandoned in favour of https://github.com/Vonage/vonage-laravel. Please use that, and open tickets in that repo if required, thanks.
I had an issue regarding with the API Credentials whereas I already used the given credentials then I got an error that says: "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 ".
Thing is I already added it on my .env and config/nexmo.php files.