Class Guzzle\Plugin\Oauth\OauthPlugin

InheritanceGuzzle\Plugin\Oauth\OauthPlugin
ImplementsSymfony\Component\EventDispatcher\EventSubscriberInterface

OAuth signing plugin

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$config Guzzle\Common\Collection Configuration settings Guzzle\Plugin\Oauth\OauthPlugin

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__construct() Create a new OAuth 1.0 plugin Guzzle\Plugin\Oauth\OauthPlugin
generateNonce() Returns a Nonce Based on the unique id and URL. This will allow for multiple requests in parallel with the same exact timestamp to use separate nonce's. Guzzle\Plugin\Oauth\OauthPlugin
getParamsToSign() Get all of the parameters required to sign a request including: The oauth params The request GET params * The params passed in the POST body (with a content-type of application/x-www-form-urlencoded) Guzzle\Plugin\Oauth\OauthPlugin
getSignature() Calculate signature for request Guzzle\Plugin\Oauth\OauthPlugin
getStringToSign() Calculate string to sign Guzzle\Plugin\Oauth\OauthPlugin
getSubscribedEvents() Guzzle\Plugin\Oauth\OauthPlugin
getTimestamp() Gets timestamp from event or create new timestamp Guzzle\Plugin\Oauth\OauthPlugin
onRequestBeforeSend() Request before-send event handler Guzzle\Plugin\Oauth\OauthPlugin
shouldPostFieldsBeSigned() Decide whether the post fields should be added to the base string that Oauth signs. Guzzle\Plugin\Oauth\OauthPlugin

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
getOauthParams() Get the oauth parameters as named by the oauth spec Guzzle\Plugin\Oauth\OauthPlugin
prepareParameters() Convert booleans to strings, removed unset parameters, and sorts the array Guzzle\Plugin\Oauth\OauthPlugin

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
REQUEST_METHOD_HEADER 'header' Consumer request method constants. See http://oauth.net/core/1.0/#consumer_req_param Guzzle\Plugin\Oauth\OauthPlugin
REQUEST_METHOD_QUERY 'query' Guzzle\Plugin\Oauth\OauthPlugin

Property Details

$config protected property

Configuration settings

Method Details

__construct() public method

Create a new OAuth 1.0 plugin

public void __construct ( $config )
$config array

Configuration array containing these parameters:

- string 'request_method'       Consumer request method. Use the class constants.
- string 'callback'             OAuth callback
- string 'consumer_key'         Consumer key
- string 'consumer_secret'      Consumer secret
- string 'token'                Token
- string 'token_secret'         Token secret
- string 'verifier'             OAuth verifier.
- string 'version'              OAuth version.  Defaults to 1.0
- string 'signature_method'     Custom signature method
- bool   'disable_post_params'  Set to true to prevent POST parameters from being signed
- array|Closure 'signature_callback' Custom signature callback that accepts a string to sign and a signing key
generateNonce() public method

Returns a Nonce Based on the unique id and URL. This will allow for multiple requests in parallel with the same exact timestamp to use separate nonce's.

public string generateNonce ( Guzzle\Http\Message\RequestInterface $request )
$request Guzzle\Http\Message\RequestInterface

Request to generate a nonce for

getOauthParams() protected method

Get the oauth parameters as named by the oauth spec

protected Guzzle\Common\Collection getOauthParams ( $timestamp, $nonce )
$timestamp
$nonce
getParamsToSign() public method

Get all of the parameters required to sign a request including: The oauth params The request GET params * The params passed in the POST body (with a content-type of application/x-www-form-urlencoded)

public array getParamsToSign ( Guzzle\Http\Message\RequestInterface $request, $timestamp, $nonce )
$request Guzzle\Http\Message\RequestInterface

Request to generate a signature for

$timestamp integer

Timestamp to use for nonce

$nonce string
getSignature() public method

Calculate signature for request

public string getSignature ( Guzzle\Http\Message\RequestInterface $request, $timestamp, $nonce )
$request Guzzle\Http\Message\RequestInterface

Request to generate a signature for

$timestamp integer

Timestamp to use for nonce

$nonce string
getStringToSign() public method

Calculate string to sign

public string getStringToSign ( Guzzle\Http\Message\RequestInterface $request, $timestamp, $nonce )
$request Guzzle\Http\Message\RequestInterface

Request to generate a signature for

$timestamp int

Timestamp to use for nonce

$nonce string
getSubscribedEvents() public static method

public static void getSubscribedEvents ( )
getTimestamp() public method

Gets timestamp from event or create new timestamp

public int getTimestamp ( Guzzle\Common\Event $event )
$event Guzzle\Common\Event

Event containing contextual information

onRequestBeforeSend() public method

Request before-send event handler

public array onRequestBeforeSend ( Guzzle\Common\Event $event )
$event Guzzle\Common\Event

Event received

throws InvalidArgumentException
prepareParameters() protected method

Convert booleans to strings, removed unset parameters, and sorts the array

protected array prepareParameters ( $data )
$data array

Data array

shouldPostFieldsBeSigned() public method

Decide whether the post fields should be added to the base string that Oauth signs.

This implementation is correct. Non-conformant APIs may require that this method be overwritten e.g. the Flickr API incorrectly adds the post fields when the Content-Type is 'application/x-www-form-urlencoded'

public bool shouldPostFieldsBeSigned ( $request )
$request
return bool

Whether the post fields should be signed or not