GuzzleBundleSasTokenPlugin
This plugin integrates SAS Token (Azure) functionality into Guzzle Bundle, a bundle for building RESTful web service clients.
Requirements
Installation
Using composer:
composer.json
{
"require": {
"moux2003/guzzle-bundle-sastoken-plugin": "~1.0"
}
}
command line
$ composer require moux2003/guzzle-bundle-sastoken-plugin
Usage
Enable bundle
# app/AppKernel.php
new EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle([
new Moux2003\GuzzleBundleSasTokenPlugin\GuzzleBundleSasTokenPlugin(),
])
Basic configuration
# app/config/config.yml
eight_points_guzzle:
clients:
api_azure:
base_url: "https://namespace.windows.net"
# define headers, options
# plugin settings
plugin:
sasToken:
connectionString: "Endpoint=scheme://namespace.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=HaShEdKey"
expires: 60 # optional
Usage with guzzle
<?php
$sasToken = new \Moux2003\GuzzleBundleSasTokenPlugin\Middleware\SasTokenAuthMiddleware($connectionString);
$stack = \GuzzleHttp\HandlerStack::create();
// Add the sasToken middleware to the handler stack.
$stack->push($sasToken->attach());
$client = new \GuzzleHttp\Client(['handler' => $stack]);
$response = $client->post('https://namespace.windows.net/hubname/messages?api-version=2013-10');
License
This middleware is licensed under the MIT License - see the LICENSE file for details