Skip to content

Commit edb14c9

Browse files
authored
FFWEB-3052: Add support to API key authorization
Add support to API key authorization
1 parent b35a033 commit edb14c9

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Changelog
2+
## Unreleased
3+
### Added
4+
- Add support to API key authorization
5+
26
## [v0.9.8] - 2024.01.16
37
### Changed
48
Compatibility

src/Client/ClientBuilder.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class ClientBuilder
2525
/** @var string */
2626
private $version = Version::NG;
2727

28+
/** @var string */
29+
private $apiKey = '';
30+
2831
public function withServerUrl(string $serverUrl): ClientBuilder
2932
{
3033
$this->serverUrl = (string) new ServerUrl($serverUrl);
@@ -37,6 +40,13 @@ public function withCredentials(Credentials $credentials): ClientBuilder
3740
return $this;
3841
}
3942

43+
public function withApiKey(string $apiKey): ClientBuilder
44+
{
45+
$this->apiKey = $apiKey;
46+
47+
return $this;
48+
}
49+
4050
public function withVersion(string $version): ClientBuilder
4151
{
4252
$this->version = $version;
@@ -60,6 +70,12 @@ public function build(): ClientInterface
6070

6171
private function ngConfig(array $config): array
6272
{
73+
if (!empty($this->apiKey)) {
74+
$config['headers']['X-FF-API-Key'] = $this->apiKey;
75+
76+
return $config;
77+
}
78+
6379
return ['auth' => $this->credentials->getAuth()] + $config;
6480
}
6581

0 commit comments

Comments
 (0)