diff --git a/src/Common/Service/AbstractService.php b/src/Common/Service/AbstractService.php index 1fafd42..4fcfcee 100644 --- a/src/Common/Service/AbstractService.php +++ b/src/Common/Service/AbstractService.php @@ -132,7 +132,7 @@ protected function determineRequestUriFromPath($path) $path = substr($path, 1); } - $uri->setPath($uri->getPath() . '/' . $path); + $uri->setPath(rtrim($uri->getPath(), '/') . '/' . $path); } return $uri; diff --git a/src/OAuth1/Service/FitBit.php b/src/OAuth1/Service/FitBit.php index d2ed3bd..788f252 100644 --- a/src/OAuth1/Service/FitBit.php +++ b/src/OAuth1/Service/FitBit.php @@ -55,4 +55,25 @@ protected function parseAccessTokenResponse($responseBody) return $token; } + /** + * Builds the authorization header array. + * + * @return array + */ + protected function getBasicAuthorizationHeaderInfo() + { + $dateTime = new \DateTime(); + // Substracting 330 (5mins and 30s) seconds because sometimes execution is late + $timestamp = $dateTime->format('U') - 330; + $headerParameters = [ + 'oauth_callback' => $this->credentials->getCallbackUrl(), + 'oauth_consumer_key' => $this->credentials->getConsumerId(), + 'oauth_nonce' => $this->generateNonce(), + 'oauth_signature_method' => $this->getSignatureMethod(), + 'oauth_timestamp' => $timestamp, + 'oauth_version' => $this->getVersion(), + ]; + + return $headerParameters; + } } diff --git a/tests/Unit/OAuth2/Service/DeviantArtTest.php b/tests/Unit/OAuth2/Service/DeviantArtTest.php index cce1d7c..d13bf56 100644 --- a/tests/Unit/OAuth2/Service/DeviantArtTest.php +++ b/tests/Unit/OAuth2/Service/DeviantArtTest.php @@ -77,7 +77,7 @@ public function testBaseApiUriIsCorrect() $service->expects($this->once())->method('httpRequest')->willReturnArgument(0); $this->assertEquals( - 'https://www.deviantart.com/api/v1/oauth2//api/method', + 'https://www.deviantart.com/api/v1/oauth2/api/method', (string) $service->request('/api/method') ); }