Skip to content

Commit 1cbe51d

Browse files
Added JWT support (#43)
1 parent 260f5da commit 1cbe51d

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/Api/AbstractApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ abstract class AbstractApi implements ApiInterface
3030
*
3131
* @var string
3232
*/
33-
const URI_SEPARATOR = '/';
33+
protected const URI_SEPARATOR = '/';
3434

3535
/**
3636
* The http methods client.

src/Client.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,25 @@
4040
class Client
4141
{
4242
/**
43-
* The oauth token authentication method.
43+
* The OAuth token authentication method.
4444
*
4545
* @var string
4646
*/
47-
const AUTH_OAUTH_TOKEN = 'oauth_token';
47+
public const AUTH_OAUTH_TOKEN = 'oauth_token';
4848

4949
/**
50-
* The http password authentication method.
50+
* The HTTP password authentication method.
5151
*
5252
* @var string
5353
*/
54-
const AUTH_HTTP_PASSWORD = 'http_password';
54+
public const AUTH_HTTP_PASSWORD = 'http_password';
55+
56+
/**
57+
* The JSON Web Token authentication method.
58+
*
59+
* @var string
60+
*/
61+
public const AUTH_JWT = 'jwt';
5562

5663
/**
5764
* The bitbucket http client builder.

src/HttpClient/Plugin/Authentication.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ protected static function buildAuthorizationHeader(string $method, string $token
8282
return sprintf('Basic %s', base64_encode($token.':'.$password));
8383
case Client::AUTH_OAUTH_TOKEN:
8484
return sprintf('Bearer %s', $token);
85+
case Client::AUTH_JWT:
86+
return sprintf('JWT %s', $token);
8587
}
8688

8789
throw new RuntimeException(sprintf('Authentication method "%s" not implemented.', $method));

0 commit comments

Comments
 (0)