Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  apple music api does not accept the normalized version of authorization header
  • Loading branch information
Baptouuuu committed Apr 12, 2020
2 parents 26775aa + 9f6a532 commit 3c12def
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/SDK/Catalog/Catalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Innmind\TimeContinuum\Clock;
use Innmind\HttpTransport\Transport;
use Innmind\Http\{
Header\Authorization,
Header,
Message\Request\Request,
Message\Method,
ProtocolVersion,
Expand All @@ -34,13 +34,13 @@ final class Catalog implements CatalogInterface
{
private Clock $clock;
private Transport $fulfill;
private Authorization $authorization;
private Header $authorization;
private Storefront\Id $storefront;

public function __construct(
Clock $clock,
Transport $fulfill,
Authorization $authorization,
Header $authorization,
Storefront\Id $storefront
) {
$this->clock = $clock;
Expand Down
5 changes: 2 additions & 3 deletions src/SDK/Library/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
ProtocolVersion,
Headers,
Header,
Header\Authorization,
};
use Innmind\Url\Url;
use Innmind\Json\Json;
Expand All @@ -29,12 +28,12 @@
final class Library implements LibraryInterface
{
private Transport $fulfill;
private Authorization $authorization;
private Header $authorization;
private Header $userToken;

public function __construct(
Transport $fulfill,
Authorization $authorization,
Header $authorization,
Header $userToken
) {
$this->fulfill = $fulfill;
Expand Down
8 changes: 5 additions & 3 deletions src/SDK/SDK.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Innmind\Http\Header\{
Header,
Value\Value,
Authorization,
};
use Lcobucci\JWT\{
Builder,
Expand All @@ -28,7 +27,7 @@ final class SDK implements SDKInterface
{
private Transport $transport;
private Clock $clock;
private Authorization $authorization;
private Header $authorization;

public function __construct(
Clock $clock,
Expand All @@ -49,7 +48,10 @@ public function __construct(

$this->clock = $clock;
$this->transport = new HttpTransport\AppleMusic($transport);
$this->authorization = Authorization::of('Bearer', (string) $jwt);
$this->authorization = new Header(
'Authorization',
new Value('Bearer '.(string) $jwt),
);
}

public function storefronts(): Storefronts
Expand Down
6 changes: 3 additions & 3 deletions src/SDK/Storefronts/Storefronts.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
};
use Innmind\HttpTransport\Transport;
use Innmind\Http\{
Header\Authorization,
Header,
Message\Request\Request,
Message\Method,
ProtocolVersion,
Expand All @@ -22,9 +22,9 @@
final class Storefronts implements StorefrontsInterface
{
private Transport $fulfill;
private Authorization $authorization;
private Header $authorization;

public function __construct(Transport $fulfill, Authorization $authorization)
public function __construct(Transport $fulfill, Header $authorization)
{
$this->fulfill = $fulfill;
$this->authorization = $authorization;
Expand Down
3 changes: 2 additions & 1 deletion tests/SDK/SDKTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public function testInterface()
->expects($this->any())
->method('__invoke')
->with($this->callback(static function($request) {
$jwt = first($request->headers()->get('authorization')->values())->parameter();
$header = first($request->headers()->get('authorization')->values())->toString();
$jwt = substr($header, 7); // remove Bearer
$jwt = (new Parser)->parse($jwt);

return $jwt->getHeader('kid') === 'AAAAAAAAAA' &&
Expand Down

0 comments on commit 3c12def

Please sign in to comment.