|
23 | 23 | use GuzzleHttp\Exception\ServerException; |
24 | 24 | use OpenTok\Exception\BroadcastException; |
25 | 25 | use GuzzleHttp\Exception\RequestException; |
| 26 | +use InvalidArgumentException; |
26 | 27 | use OpenTok\Exception\ArchiveDomainException; |
27 | 28 | use OpenTok\Exception\AuthenticationException; |
28 | 29 | use OpenTok\Exception\BroadcastDomainException; |
@@ -123,9 +124,18 @@ public function isConfigured() |
123 | 124 |
|
124 | 125 | private function createAuthHeader(): string |
125 | 126 | { |
126 | | - if (Validators::isVonageKeypair($this->apiKey, $this->apiSecret)) { |
127 | | - $tokenGenerator = new TokenGenerator($this->apiKey, file_get_contents($this->apiSecret)); |
128 | | - return $tokenGenerator->generate(); |
| 127 | + try { |
| 128 | + if (Validators::isVonageKeypair($this->apiKey, $this->apiSecret)) { |
| 129 | + $secret = $this->apiSecret; |
| 130 | + if (file_exists($this->apiSecret)) { |
| 131 | + $secret = file_get_contents($this->apiSecret); |
| 132 | + } |
| 133 | + |
| 134 | + $tokenGenerator = new TokenGenerator($this->apiKey, $secret); |
| 135 | + return $tokenGenerator->generate(); |
| 136 | + } |
| 137 | + } catch (InvalidArgumentException) { |
| 138 | + // Do nothing, fall back to legacy token generation |
129 | 139 | } |
130 | 140 |
|
131 | 141 | $token = [ |
@@ -1084,4 +1094,14 @@ private function isDebug(): bool |
1084 | 1094 | { |
1085 | 1095 | return defined('OPENTOK_DEBUG'); |
1086 | 1096 | } |
| 1097 | + |
| 1098 | + public function getApiKey(): string |
| 1099 | + { |
| 1100 | + return $this->apiKey; |
| 1101 | + } |
| 1102 | + |
| 1103 | + public function getApiSecret(): string |
| 1104 | + { |
| 1105 | + return $this->apiSecret; |
| 1106 | + } |
1087 | 1107 | } |
0 commit comments