@@ -28,24 +28,6 @@ via **yarn**:
28
28
$ yarn add bitbucket
29
29
```
30
30
31
- ## Authentication
32
-
33
- Bitbucket supports different authentication strategies:
34
-
35
- - OAuth 2
36
- - App passwords
37
- - Basic auth
38
-
39
- ### Basic auth
40
-
41
- ``` javascript
42
- const { Bitbucket } = require (' bitbucket' )
43
-
44
- const bitbucket = new Bitbucket ({
45
- auth: ' ' ,
46
- })
47
- ```
48
-
49
31
## Usage
50
32
51
33
### Browser
@@ -80,7 +62,13 @@ const clientOptions = {
80
62
const bitbucket = new Bitbucket (clientOptions)
81
63
```
82
64
83
- #### Authentication
65
+ ### Authentication
66
+
67
+ Bitbucket supports different authentication strategies:
68
+
69
+ - OAuth 2
70
+ - App passwords
71
+ - Basic auth
84
72
85
73
** Using ` username ` and ` password ` ** :
86
74
@@ -107,6 +95,68 @@ const clientOptions = {
107
95
const bitbucket = new Bitbucket (clientOptions)
108
96
```
109
97
98
+ ** Using ` Client Credentials Grant ` ** :
99
+
100
+ ``` js
101
+ const clientOptions = {
102
+ authStrategy: ' OAuth' ,
103
+ auth: {
104
+ grant_type: ' clientCredentialsGrant' ,
105
+ client_id: ' client_id' ,
106
+ client_secret: ' client_secret' ,
107
+ },
108
+ }
109
+
110
+ const bitbucket = new Bitbucket (clientOptions)
111
+ ```
112
+
113
+ ** Using ` Authorization Code Grant ` ** :
114
+
115
+ ``` js
116
+ const clientOptions = {
117
+ authStrategy: ' OAuth' ,
118
+ auth: {
119
+ grant_type: ' authorizationCodeGrant' ,
120
+ client_id: ' client_id' ,
121
+ client_secret: ' client_secret' ,
122
+ code: ' code' ,
123
+ },
124
+ }
125
+
126
+ const bitbucket = new Bitbucket (clientOptions)
127
+ ```
128
+
129
+ ** Using ` Resource Owner Password Credentials Grant ` ** :
130
+
131
+ ``` js
132
+ const clientOptions = {
133
+ authStrategy: ' OAuth' ,
134
+ auth: {
135
+ grant_type: ' resourceOwnerPasswordCredentialsGrant' ,
136
+ client_id: ' client_id' ,
137
+ client_secret: ' client_secret' ,
138
+ username: ' username' ,
139
+ password: ' password' ,
140
+ },
141
+ }
142
+
143
+ const bitbucket = new Bitbucket (clientOptions)
144
+ ```
145
+
146
+ ** Using ` Bitbucket Cloud JWT Grant ` ** :
147
+
148
+ ``` js
149
+ const clientOptions = {
150
+ authStrategy: ' OAuth' ,
151
+ auth: {
152
+ grant_type: ' urn:bitbucket:oauth2:jwt' ,
153
+ jwt_token: ' jwt_token' ,
154
+ },
155
+ }
156
+
157
+ const bitbucket = new Bitbucket (clientOptions)
158
+ ```
159
+
110
160
#### API Methods
111
161
112
162
** async/await**
0 commit comments