Closed turigeza closed 4 years ago
Solved. Your should instantiate Buzz with middleware, otherwise Header token not be added.
$curl = new \Buzz\Client\Curl();
$browser = new \Buzz\Browser($curl);
$browser->addMiddleware(
new \Buzz\Middleware\BearerAuthMiddleware('token')
);
$adapter = new BuzzAdapter(null, $browser);
$digitalocean = new DigitalOceanV2($adapter);
Does this mean the examples need to be updated?
Does this mean the examples need to be updated?
seems not :/
@consigliere23 seems? Examples not working anymore. It's exactly.
If the examples are out of date, can you help by creating a pull request for the changes required?
~Moving to part of the v4 design issue #249. I am planning to smash out a fresh package for v4 which will feel like the old package, but have none of the issues and all of the compatibility. ;)~
EDIT: Robust implementations of Buzz 0.16 and Guzzle 6 adapters are implemented in the 3.0.0 release.
New code for v3 of the library:
<?php
require_once 'vendor/autoload.php';
$digitalocean = new DigitalOceanV2\Client();
$digitalocean->authenticate('your_access_token');
No need to do anything with adapters. As long as the current version of Guzzle or Buzz is installed, we will automatically discover it.
Following you example in the readme I am getting this error. I have tried to regenerate the API key but still the same. Any ideas ? Thank you.
Fatal error: Uncaught DigitalOceanV2\Exception\HttpException: Unable to authenticate you. in /websites/aapi.younit.app/vendor/toin0u/digitalocean-v2/src/Adapter/BuzzAdapter.php:145 Stack trace: #0 /websites/aapi.younit.app/vendor/toin0u/digitalocean-v2/src/Adapter/BuzzAdapter.php(130): DigitalOceanV2\Adapter\BuzzAdapter->handleError(Object(Buzz\Message\Response)) #1 /websites/aapi.younit.app/vendor/toin0u/digitalocean-v2/src/Adapter/BuzzAdapter.php(50): DigitalOceanV2\Adapter\BuzzAdapter->handleResponse(Object(Buzz\Message\Response)) #2 /websites/aapi.younit.app/vendor/toin0u/digitalocean-v2/src/Api/Domain.php(31): DigitalOceanV2\Adapter\BuzzAdapter->get('https://api.dig...') #3 /websites/aapi.younit.app/cluster/check_ssh_key.php(28): DigitalOceanV2\Api\Domain->getAll() #4 /websites/aapi.younit.app/cluster/check_ssh_key.php(31): {closure}() #5 {main} thrown in /websites/aapi.younit.app/vendor/toin0u/digitalocean-v2/src/Adapter/BuzzAdapter.php on line 145
PHP Version 7.2.15-0ubuntu0.18.04.1 cURL support enabled cURL Information 7.58.0
So it seems that GuzzleHttpAdapter works fine. Only BuzzAdapter giving me the grief. Instead of this
I use this