You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+74-9Lines changed: 74 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -42,24 +42,89 @@ We are decoupled from any HTTP messaging client with help by [HTTPlug](http://ht
42
42
43
43
## Usage
44
44
45
-
The main point of entry is the `Bitbucket\Client` class. Simply create a new instance of that, and you're good to go!
45
+
The main point of entry is the `Bitbucket\Client` class. Simply create a new instance of that, authenticate, and you're good to go! As of time of writing (Saturday 29th June 2019), every endpoint (excluding issue export and import) available on the Bitbucket API 2.0 is also available through this PHP client. We'd recommend looking through the [Bitbucket documentation](https://developer.atlassian.com/bitbucket/api/2/reference/), and also the [source code](https://github.com/BitbucketAPI/Client/tree/3.0/src) to get a full picture of what is available to use.
46
46
47
-
Practically, you will also want to set authentication details before calling any of the endpoint, however, this is not required to call endpoints for which authentication is not needed. We support logging in with an OAuth2 token, or with a username and password.
47
+
### Authentication
48
+
49
+
There are three ways to authenticate our client:
50
+
51
+
#### OAuth 2 Token
52
+
53
+
The most common way to authenticate is using an OAuth 2 token. You will need to generate this by some means outside of the library, and then provide it as below:
54
+
55
+
```php
56
+
$c = new Bitbucket\Client();
57
+
58
+
$c->authenticate(
59
+
Bitbucket\Client::AUTH_OAUTH_TOKEN,
60
+
'your-token-here'
61
+
);
62
+
```
63
+
64
+
#### HTTP Password
65
+
66
+
It is possible to login using a username and password combination. This method is not recommended for production use, however you find it useful never the less:
48
67
49
68
```php
50
-
<?php
69
+
$c = new Bitbucket\Client();
70
+
71
+
$c->authenticate(
72
+
Bitbucket\Client::AUTH_HTTP_PASSWORD,
73
+
'your-username-here',
74
+
'your-password-here'
75
+
);
76
+
```
77
+
78
+
#### JSON Web Token
51
79
52
-
use Bitbucket\Client;
80
+
Finally, we support logging in using JSON web tokens (JWTs). This method is exclusively required by some of Bitbucket's API endpoints, such as the addons API. Generate your JWT, perahps using [lcobucci/jwt](https://github.com/lcobucci/jwt/tree/3.3.2), then provide it as below:
As of time of writing (Saturday 29th June 2019), every endpoint (excluding issue export and import) available on the Bitbucket API 2.0 is also available through this PHP client. I'd recommend looking through the [Bitbucket documentation](https://developer.atlassian.com/bitbucket/api/2/reference/), and also the [source code](https://github.com/BitbucketAPI/Client/tree/3.0/src) to get a full picture of what is available to use.
92
+
### Examples
93
+
94
+
In the following examples, `$client` will be an authenticated client, as above.
95
+
96
+
#### Example 1
97
+
98
+
It is possible to show basic information about the currently logged in user:
99
+
100
+
```php
101
+
$currentUser = $client->currentUser()->show();
102
+
```
103
+
104
+
#### Example 2
105
+
106
+
It is possible to grab a repository as follows:
107
+
108
+
```php
109
+
$repository = $client->repositories()
110
+
->workspaces('atlassian')
111
+
->show('stash-example-plugin');
112
+
```
113
+
114
+
#### Example 3
115
+
116
+
We support automatic pagination without you having to lift a finger. The following example gets all branches of a repository:
0 commit comments