Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function getRequestTokenEndpoint()
 {
     $uri = new Url($this->baseApiUri . 'oauth/request_token');
     if (count($this->getScopes())) {
         $uri->getQuery()->modify('scope=' . implode('%20', $this->getScopes()));
     }
     return $uri;
 }
Exemple #2
0
 public function getAuthorizationUri(array $additionalParameters = [])
 {
     $requestToken = empty($additionalParameters['request_token']) ? $this->requestRequestToken() : $additionalParameters['request_token'];
     $redirectUri = new Url($this->credentials->getCallbackUrl());
     $redirectUri->getQuery()->modify(['code' => $requestToken]);
     $parameters = array_merge(['request_token' => $requestToken, 'redirect_uri' => (string) $redirectUri], $additionalParameters);
     // Build the url
     $url = $this->getAuthorizationEndpoint();
     $url->getQuery()->modify($parameters);
     return $url;
 }
Exemple #3
0
 public function testClone()
 {
     $url = new Url('http://domain');
     $clonedUrl = clone $url;
     $this->assertInstanceOf('\\OAuth\\Common\\Http\\Url', $clonedUrl, 'Same class');
     $this->assertEquals('domain', $url->getHost()->get());
     $this->assertEquals('domain', $clonedUrl->getHost()->get());
     // Change value
     $url->getHost()->set('another-domain');
     // Value in original url is changed
     $this->assertEquals('another-domain', $url->getHost()->get());
     // Value in clone url not changed
     $this->assertEquals('domain', $clonedUrl->getHost()->get());
 }
Exemple #4
0
 /**
  * @param Url $uri
  * @param array $params
  * @param string $method
  *
  * @return string
  */
 public function getSignature(Url $uri, array $params, $method = 'POST')
 {
     parse_str($uri->getQuery(), $queryStringData);
     foreach (array_merge($queryStringData, $params) as $key => $value) {
         $signatureData[rawurlencode($key)] = rawurlencode($value);
     }
     ksort($signatureData);
     // determine base uri
     $baseUri = $uri->getScheme() . '://' . $uri->getAuthority();
     if ('/' === $uri->getPath()->getUriComponent()) {
         $baseUri .= '/';
     } else {
         $baseUri .= $uri->getPath()->getUriComponent();
     }
     $baseString = strtoupper($method) . '&';
     $baseString .= rawurlencode($baseUri) . '&';
     $baseString .= rawurlencode($this->buildSignatureDataString($signatureData));
     return base64_encode($this->hash($baseString));
 }
Exemple #5
0
 /**
  * Replaces "/{apiVersion}" to configured proper api version, or remove version from URI if it's have not configured
  *
  * @param Url $uri
  *
  * @return Url
  */
 protected function injectApiVersionToUri(Url $uri)
 {
     $uri->setPath(str_replace('/{apiVersion}', $this->getApiVersionString(), '/' . urldecode($uri->getPath())));
     return $uri;
 }