Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"api-clients/transport": "^3.1",
"api-clients/travis": "^1.0",
"kelunik/link-header-rfc5988": "^1.0",
"lcobucci/jwt": "^3.3",
"react/promise-stream": "^1.0 || ^0.1.1",
"wyrihaximus/react-stream-base64": "^1.0",
"wyrihaximus/react-stream-json": "^1.0"
Expand Down
61 changes: 60 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions src/Authentication/JWT.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php declare(strict_types=1);

namespace ApiClients\Client\Github\Authentication;

use ApiClients\Client\Github\AuthenticationInterface;
use ApiClients\Foundation\Options as FoundationOptions;
use ApiClients\Foundation\Transport\Options as TransportOptions;
use ApiClients\Middleware\BearerAuthorization\BearerAuthorizationHeaderMiddleware;
use ApiClients\Middleware\BearerAuthorization\Options as BearerAuthorizationHeaderMiddlewareOptions;
use Lcobucci\JWT\Token;

final class JWT implements AuthenticationInterface
{
/**
* @var Token
*/
private $token;

public function __construct(Token $token)
{
$this->token = $token;
}

public function getOptions(): array
{
return [
FoundationOptions::TRANSPORT_OPTIONS => [
TransportOptions::MIDDLEWARE => [
BearerAuthorizationHeaderMiddleware::class,
],
TransportOptions::DEFAULT_REQUEST_OPTIONS => [
BearerAuthorizationHeaderMiddleware::class => [
BearerAuthorizationHeaderMiddlewareOptions::TOKEN => $this->token,
],
],
],
];
}
}