public function build() { Preconditions::checkNotNull($this->api, "You must specify a valid api through the provider() method"); Preconditions::checkEmptyString($this->apiKey, "You must provide an api key"); Preconditions::checkEmptyString($this->apiSecret, "You must provide an api secret"); return $this->api->createService(new OAuthConfig($this->apiKey, $this->apiSecret, $this->callback, $this->signatureType, $this->scope)); }
public function extract($response) { Preconditions::checkEmptyString($response, "Response body is incorrect. " . "Can't extract a token from an empty string"); $token = $this->_extract($response, self::TOKEN_REGEX); $secret = $this->_extract($response, self::SECRET_REGEX); return new Token($token, $secret, $response); }
private function checkPreconditions(OAuthRequest $request) { Preconditions::checkNotNull($request, "Cannot extract a header from a null object"); $params = $request->getOauthParameters(); if (!$params) { throw new OAuthParametersMissingException($request); } }
public function extract($response) { Preconditions::checkEmptyString($response, "Cannot extract a token from a null or empty String"); if (preg_match($this->accessTokenPattern, $response, $matches)) { return new Token($matches[1], "", $response); } else { throw new OAuthException("Cannot extract an acces token. Response was: " . $response); } }
public function getAuthorizationUrl(OAuthConfig $config) { Preconditions::checkValidUrl($config->getCallback(), "Must provide a valid url as callback. Live does not support OOB"); if ($config->hasScope()) { return sprintf(self::SCOPED_AUTHORIZE_URL, $config->getApiKey(), URLUtils::formURLEncode($config->getCallback()), URLUtils::formURLEncode($config->getScope())); } else { return sprintf(self::AUTHORIZE_URL, $config->getApiKey(), URLUtils::formURLEncode($config->getCallback())); } }
public function getSignature($baseString, $apiSecret, $tokenSecret) { try { Preconditions::checkEmptyString($apiSecret, "Api secret cant be null or empty string"); return URLUtils::percentEncode($apiSecret) . '&' . URLUtils::percentEncode($tokenSecret); } catch (\Exception $e) { throw new OAuthSignatureException($baseString, $e); } }
public function extract($response) { Preconditions::checkEmptyString($response, "Response body is incorrect. " . "Can't extract a token from an empty string"); if (preg_match(self::TOKEN_REGEX, $response, $matches)) { $token = URLUtils::formURLDecode($matches[1]); return new Token($token, self::EMPTY_SECRET, $response); } else { throw new OAuthException("Response body is incorrect. Can't extract a " . "token from this: '" . $response . "'", null); } }
public function getAuthorizationUrl(OAuthConfig $config) { Preconditions::checkValidUrl($config->getCallback(), "Must provide a valid url as callback. Foursquare2 does not support OOB"); return sprintf(self::AUTHORIZATION_URL, $config->getApiKey(), URLUtils::formURLEncode($config->getCallback())); }
public function __construct($value) { Preconditions::checkNotNull($value, "Must provide a valid string as verifier"); $this->value = $value; }