Nexmo / nexmo-laravel

Add Vonage functionality such as SMS and voice calling to your Laravel app with this Laravel Service Provider.
MIT License
318 stars 79 forks source link

Nexmo API credentials error #25

Closed leonardeveloper closed 6 years ago

leonardeveloper commented 6 years ago

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 .

I already added it on my .env and config/nexmo.php files. I'm currently using Laravel 5.5

mheap commented 6 years ago

Thanks @leonardeveloper.

Do you have a nexmo entry in config/services.php?

Your config/nexmo.php file should look like the following (generated by running php artisan vendor:publish:

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | API Credentials
    |--------------------------------------------------------------------------
    |
    | If you're using API credentials, change these settings. Get your
    | credentials from https://dashboard.nexmo.com | 'Settings'.
    |
    */

    'api_key'    => function_exists('env') ? env('NEXMO_KEY', '') : '',
    'api_secret' => function_exists('env') ? env('NEXMO_SECRET', '') : '',

    /*
    |--------------------------------------------------------------------------
    | Signature Secret
    |--------------------------------------------------------------------------
    |
    | If you're using a signature secret, use this section. This can be used
    | without an `api_secret` for some APIs, as well as with an `api_secret`
    | for all APIs.
    |
    */

    'signature_secret' => function_exists('env') ? env('NEXMO_SIGNATURE_SECRET', '') : '',

    /*
    |--------------------------------------------------------------------------
    | Private Key
    |--------------------------------------------------------------------------
    |
    | Private keys are used to generate JWTs for authentication. Generation is
    | handled by the library. JWTs are required for newer APIs, such as voice
    | and media
    |
    */

    'private_key' => function_exists('env') ? env('NEXMO_PRIVATE_KEY', '') : '',
    'application_id' => function_exists('env') ? env('NEXMO_APPLICATION_ID', '') : '',

];
leonardeveloper commented 6 years ago

Here is my config/services.php

`<?php

return [

/*
|--------------------------------------------------------------------------
| Third Party Services
|--------------------------------------------------------------------------
|
| This file is for storing the credentials for third party services such
| as Stripe, Mailgun, SparkPost and others. This file provides a sane
| default location for this type of information, allowing packages
| to have a conventional place to find your various credentials.
|
*/

'mailgun' => [
    'domain' => env('MAILGUN_DOMAIN'),
    'secret' => env('MAILGUN_SECRET'),
],

'ses' => [
    'key' => env('SES_KEY'),
    'secret' => env('SES_SECRET'),
    'region' => 'us-east-1',
],

'sparkpost' => [
    'secret' => env('SPARKPOST_SECRET'),
],

'stripe' => [
    'model' => App\User::class,
    'key' => env('STRIPE_KEY'),
    'secret' => env('STRIPE_SECRET'),
],

]; And yes myconfig/nexmo.php` is the same with your code.

mheap commented 6 years ago

I've just created a new Laravel 5.5 project and things seem to be working fine.

Bootstrap the project:

composer create-project --prefer-dist laravel/laravel blog "5.5.*"
cd blog
composer require nexmo/laravel

Update routes/web.php to send an SMS to test:

Route::get('/', function () {
    Nexmo::message()->send(['from' => "TEST", 'to' => "<number>", 'text' => "Hello World"]);
    return view('welcome');
});
php artisan serve

Visit http://127.0.0.1:8000/ - we should get the error you described

Edit .env and add your credentials:

NEXMO_KEY=
NEXMO_SECRET=

Visit http://127.0.0.1:8000/ again - the message should be sent fine

leonardeveloper commented 6 years ago

I've just created a new Laravel project using the guide from above and got this new error message.

cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

Weird. Unsure what I've missed.

leonardeveloper commented 6 years ago

Fixed my last error message. Perhaps it's some sort of installation issue on my end that the API credentials didn't worked.

All good now. Thanks a lot.