bilan/connectlife-api-connector

get a code erro

Closed this issue · 6 comments

Hi i get a code error

In Response.php line 391:

[ErrorException]
Undefined array key "code"

Exception trace:
at /home/app/vendor/laravel/framework/src/Illuminate/Http/Client/Response.php:391
Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() at /home/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:255
Illuminate\Foundation\Bootstrap\HandleExceptions->Illuminate\Foundation\Bootstrap{closure}() at /home/app/vendor/laravel/framework/src/Illuminate/Http/Client/Response.php:391
Illuminate\Http\Client\Response->offsetGet() at /home/app/app/Services/ConnectlifeApiService.php:69
App\Services\ConnectlifeApiService->App\Services{closure}() at /home/app/vendor/laravel/framework/src/Illuminate/Cache/Repository.php:397
Illuminate\Cache\Repository->remember() at /home/app/vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php:429
Illuminate\Cache\CacheManager->__call() at /home/app/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:355
Illuminate\Support\Facades\Facade::__callStatic() at /home/app/app/Services/ConnectlifeApiService.php:32
App\Services\ConnectlifeApiService->getAccessToken() at /home/app/app/Services/ConnectlifeApiService.php:103
App\Services\ConnectlifeApiService->App\Services{closure}() at /home/app/vendor/laravel/framework/src/Illuminate/Cache/Repository.php:397
Illuminate\Cache\Repository->remember() at /home/app/vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php:429
Illuminate\Cache\CacheManager->__call() at /home/app/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:355
Illuminate\Support\Facades\Facade::__callStatic() at /home/app/app/Services/ConnectlifeApiService.php:99
App\Services\ConnectlifeApiService->devices() at /home/app/app/Services/MqttService.php:21
App\Services\MqttService->setupHaDiscovery() at /home/app/app/Console/Commands/MqttLoop.php:24
App\Console\Commands\MqttLoop->handle() at /home/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
Illuminate\Container\BoundMethod::Illuminate\Container{closure}() at /home/app/vendor/laravel/framework/src/Illuminate/Container/Util.php:41
Illuminate\Container\Util::unwrapIfClosure() at /home/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
Illuminate\Container\BoundMethod::callBoundMethod() at /home/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:35
Illuminate\Container\BoundMethod::call() at /home/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:662
Illuminate\Container\Container->call() at /home/app/vendor/laravel/framework/src/Illuminate/Console/Command.php:211
Illuminate\Console\Command->execute() at /home/app/vendor/symfony/console/Command/Command.php:326
Symfony\Component\Console\Command\Command->run() at /home/app/vendor/laravel/framework/src/Illuminate/Console/Command.php:180
Illuminate\Console\Command->run() at /home/app/vendor/symfony/console/Application.php:1096
Symfony\Component\Console\Application->doRunCommand() at /home/app/vendor/symfony/console/Application.php:324
Symfony\Component\Console\Application->doRun() at /home/app/vendor/symfony/console/Application.php:175
Symfony\Component\Console\Application->run() at /home/app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:201
Illuminate\Foundation\Console\Kernel->handle() at /home/app/artisan:35

s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service base-addon-log-level: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service base-addon-log-level successfully stopped
s6-rc: info: service base-addon-banner: stopping
s6-rc: info: service base-addon-banner successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

Hi,
its something related with getting access token. I use:
https://accounts.eu1.gigya.com/accounts.getJWT
endpoint and "eu1" in the URI suggest that other regions may have different address.

You can find out what your endpoints are by logging in swagger api:
https://api.connectlife.io/swagger/index.html

Endpoints should be visible in a browser developer tools.

I managed to find out what region names are:
https://cdns.gigya.com/js/gigya.js?apiKey=4_yhTWQmHFpZkQZDSV1uV-_A

"us1","eu1","au1","ru1","cn1","il1","il3"

What is your region?

eu1

I use several of the constans I have viewed in browsers developer tools:
$apiKey = '4_yhTWQmHFpZkQZDSV1uV-_A';
$gmid = 'gmid.ver4.AtLt3mZAMA.C8m5VqSTEQDrTRrkYYDgOaJWcyQ-XHow5nzQSXJF3EO3TnqTJ8tKUmQaaQ6z8p0s.zcTbHe6Ax6lHfvTN7JUj7VgO4x8Vl-vk1u0kZcrkKmKWw8K9r0shyut_at5Q0ri6zTewnAv2g1Dc8dauuyd-Sw.sc3';
$clientId = "5065059336212";

you can check if yours are the same.

how do i do that?

there was an error in the code, fixed here:
bc1535c