Class Oauth
Oauth 1 authentication strategy for Cake\Http\Client
This object does not handle getting Oauth access tokens from the service provider. It only handles make client requests after you have obtained the Oauth tokens.
Generally not directly constructed, but instead used by {@link \Cake\Http\Client} when $options['auth']['type'] is 'oauth'
Method Summary
-
authentication() public
Add headers for Oauth authorization.
-
baseString() public
Generate the Oauth basestring
- Querystring, request data and oauth_* parameters are combined.
- Values are sorted by name and then value.
- Request values are concatenated and urlencoded.
- The request URL (without querystring) is normalized.
- The HTTP method, URL and request parameters are concatenated and returned.
-
buildAuth() protected
Builds the Oauth Authorization header value.
-
checkSslError() protected
Check for SSL errors and throw an exception if found.
-
encode() protected
URL Encodes a value based on rules of rfc3986
-
hmacSha1() protected
Use HMAC-SHA1 signing.
This method is suitable for plain HTTP or HTTPS.
-
normalizeData() protected
Recursively convert request data into the normalized form.
-
normalizedParams() protected
Sorts and normalizes request data and oauthValues
Section 9.1.1 of Oauth spec.
- URL encode keys + values.
- Sort keys & values by byte value.
-
normalizedUrl() protected
Builds a normalized URL
Section 9.1.2. of the Oauth spec
-
plaintext() protected
Plaintext signing
This method is not suitable for plain HTTP. You should only ever use PLAINTEXT when dealing with SSL services.
-
rsaSha1() protected
Use RSA-SHA1 signing.
This method is suitable for plain HTTP or HTTPS.
Method Detail
authentication() ¶ public
authentication(Cake\Http\Client\Request $request, array<string, mixed> $credentials): Cake\Http\Client\Request
Add headers for Oauth authorization.
Parameters
-
Cake\Http\Client\Request$request The request object.
-
array<string, mixed>$credentials Authentication credentials.
Returns
Cake\Http\Client\RequestThe updated request.
Throws
Cake\Core\Exception\CakeExceptionOn invalid signature types.
baseString() ¶ public
baseString(Cake\Http\Client\Request $request, array $oauthValues): string
Generate the Oauth basestring
- Querystring, request data and oauth_* parameters are combined.
- Values are sorted by name and then value.
- Request values are concatenated and urlencoded.
- The request URL (without querystring) is normalized.
- The HTTP method, URL and request parameters are concatenated and returned.
Parameters
-
Cake\Http\Client\Request$request The request object.
-
array$oauthValues Oauth values.
Returns
stringbuildAuth() ¶ protected
buildAuth(array $data): string
Builds the Oauth Authorization header value.
Parameters
-
array$data The oauth_* values to build
Returns
stringcheckSslError() ¶ protected
checkSslError(): void
Check for SSL errors and throw an exception if found.
Returns
voidThrows
Cake\Core\Exception\CakeExceptionWhen an error is found
encode() ¶ protected
encode(string $value): string
URL Encodes a value based on rules of rfc3986
Parameters
-
string$value Value to encode.
Returns
stringhmacSha1() ¶ protected
hmacSha1(Cake\Http\Client\Request $request, array $credentials): string
Use HMAC-SHA1 signing.
This method is suitable for plain HTTP or HTTPS.
Parameters
-
Cake\Http\Client\Request$request The request object.
-
array$credentials Authentication credentials.
Returns
stringnormalizeData() ¶ protected
normalizeData(array $args, string $path = ''): array
Recursively convert request data into the normalized form.
Parameters
-
array$args The arguments to normalize.
-
string$path optional The current path being converted.
Returns
arraySee Also
normalizedParams() ¶ protected
normalizedParams(Cake\Http\Client\Request $request, array $oauthValues): string
Sorts and normalizes request data and oauthValues
Section 9.1.1 of Oauth spec.
- URL encode keys + values.
- Sort keys & values by byte value.
Parameters
-
Cake\Http\Client\Request$request The request object.
-
array$oauthValues Oauth values.
Returns
stringsorted and normalized values
normalizedUrl() ¶ protected
normalizedUrl(Psr\Http\Message\UriInterface $uri): string
Builds a normalized URL
Section 9.1.2. of the Oauth spec
Parameters
-
Psr\Http\Message\UriInterface$uri Uri object to build a normalized version of.
Returns
stringNormalized URL
plaintext() ¶ protected
plaintext(Cake\Http\Client\Request $request, array $credentials): string
Plaintext signing
This method is not suitable for plain HTTP. You should only ever use PLAINTEXT when dealing with SSL services.
Parameters
-
Cake\Http\Client\Request$request The request object.
-
array$credentials Authentication credentials.
Returns
stringAuthorization header.
rsaSha1() ¶ protected
rsaSha1(Cake\Http\Client\Request $request, array $credentials): string
Use RSA-SHA1 signing.
This method is suitable for plain HTTP or HTTPS.
Parameters
-
Cake\Http\Client\Request$request The request object.
-
array$credentials Authentication credentials.
Returns
string