From 6a80cb69e29c8a93811acc54921d6b4088262c9e Mon Sep 17 00:00:00 2001 From: Martin Pecha Date: Tue, 30 Jul 2019 23:06:59 +0200 Subject: [PATCH] add api token support --- src/Auth/APIToken.php | 25 +++++++++++++++++++++++++ tests/Auth/APITokenTest.php | 21 +++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 src/Auth/APIToken.php create mode 100644 tests/Auth/APITokenTest.php diff --git a/src/Auth/APIToken.php b/src/Auth/APIToken.php new file mode 100644 index 0000000..c1d20ff --- /dev/null +++ b/src/Auth/APIToken.php @@ -0,0 +1,25 @@ +apiToken = $apiToken; + } + + public function getHeaders(): array + { + return [ + 'Authorization' => 'Bearer ' . $this->apiToken + ]; + } +} diff --git a/tests/Auth/APITokenTest.php b/tests/Auth/APITokenTest.php new file mode 100644 index 0000000..dc6a470 --- /dev/null +++ b/tests/Auth/APITokenTest.php @@ -0,0 +1,21 @@ +getHeaders(); + + $this->assertArrayHasKey('Authorization', $headers); + + $this->assertEquals('Bearer zKq9RDO6PbCjs6PRUXF3BoqFi3QdwY36C2VfOaRy', $headers['Authorization']); + + $this->assertCount(1, $headers); + } +}