Skip to content

Commit dc1771f

Browse files
authored
Merge pull request #234 from reportportal/develop
Release 5.4.3
2 parents fd3e5af + b58c90d commit dc1771f

9 files changed

Lines changed: 723 additions & 18 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
### Added
2+
- OAuth 2.0 Password Grant authentication, check [Authentication Options](https://github.com/reportportal/client-javascript?tab=readme-ov-file#authentication-options) for more details.
13

24
## [5.4.2] - 2025-10-02
35
### Added

README.md

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,79 @@ rpClient.checkConnect().then(() => {
5050

5151
## Configuration
5252

53-
When creating a client instance, you need to specify the following options:
53+
When creating a client instance, you need to specify the following options.
5454

55-
| Option | Necessity | Default | Description |
55+
### Authentication Options
56+
57+
The client supports two authentication methods:
58+
1. **API Key Authentication** (default)
59+
2. **OAuth 2.0 Password Grant** (recommended for enhanced security)
60+
61+
**Note:**\
62+
If both authentication methods are provided, OAuth 2.0 will be used.\
63+
Either API key or complete OAuth 2.0 configuration is required to connect to ReportPortal.
64+
65+
| Option | Necessity | Default | Description |
66+
|--------|-------------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
67+
| apiKey | Conditional | | User's ReportPortal API key from which you want to send requests. It can be found on the profile page of this user. *Required only if OAuth is not configured. |
68+
| oauth | Conditional | | OAuth 2.0 configuration object. When provided, OAuth authentication will be used instead of API key. See OAuth Configuration below. |
69+
70+
#### OAuth Configuration
71+
72+
The `oauth` object supports the following properties:
73+
74+
| Property | Necessity | Default | Description |
5675
|-----------------------|------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
57-
| apiKey | Required | | User's reportportal token from which you want to send requests. It can be found on the profile page of this user. |
58-
| endpoint | Required | | URL of your server. For example, if you visit the page at 'https://server:8080/ui', then endpoint will be equal to 'https://server:8080/api/v1'. |
59-
| launch | Required | | Name of the launch at creation. |
60-
| project | Required | | The name of the project in which the launches will be created. |
61-
| headers | Optional | {} | The object with custom headers for internal http client. |
62-
| debug | Optional | false | This flag allows seeing the logs of the client. Useful for debugging. |
63-
| isLaunchMergeRequired | Optional | false | Allows client to merge launches into one at the end of the run via saving their UUIDs to the temp files at filesystem. At the end of the run launches can be merged using `mergeLaunches` method. Temp file format: `rplaunch-${launch_uuid}.tmp`. |
76+
| tokenEndpoint | Required | | OAuth 2.0 token endpoint URL for password grant flow. |
77+
| username | Required | | Username for OAuth 2.0 password grant. |
78+
| password | Required | | Password for OAuth 2.0 password grant. |
79+
| clientId | Required | | OAuth 2.0 client ID. |
80+
| clientSecret | Optional | | OAuth 2.0 client secret (optional, depending on your OAuth server configuration). |
81+
| scope | Optional | | OAuth 2.0 scope (optional, space-separated list of scopes). |
82+
83+
**Note:** The OAuth interceptor automatically handles token refresh when the token is about to expire (1 minute before expiration).
84+
85+
##### OAuth 2.0 configuration example
86+
87+
```javascript
88+
const RPClient = require('@reportportal/client-javascript');
89+
90+
const rpClient = new RPClient({
91+
endpoint: 'http://your-instance.com:8080/api/v1',
92+
launch: 'LAUNCH_NAME',
93+
project: 'PROJECT_NAME',
94+
oauth: {
95+
tokenEndpoint: 'https://your-oauth-server.com/oauth/token',
96+
username: 'your-username',
97+
password: 'your-password',
98+
clientId: 'your-client-id',
99+
clientSecret: 'your-client-secret', // optional
100+
scope: 'reportportal', // optional
101+
}
102+
});
103+
104+
rpClient.checkConnect().then(() => {
105+
console.log('You have successfully connected to the server.');
106+
}, (error) => {
107+
console.log('Error connection to server');
108+
console.dir(error);
109+
});
110+
```
111+
112+
### General Options
113+
114+
| Option | Necessity | Default | Description |
115+
|-----------------------|------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
116+
| endpoint | Required | | URL of your server. For example, if you visit the page at 'https://server:8080/ui', then endpoint will be equal to 'https://server:8080/api/v1'. |
117+
| launch | Required | | Name of the launch at creation. |
118+
| project | Required | | The name of the project in which the launches will be created. |
119+
| headers | Optional | {} | The object with custom headers for internal http client. |
120+
| debug | Optional | false | This flag allows seeing the logs of the client. Useful for debugging. |
121+
| isLaunchMergeRequired | Optional | false | Allows client to merge launches into one at the end of the run via saving their UUIDs to the temp files at filesystem. At the end of the run launches can be merged using `mergeLaunches` method. Temp file format: `rplaunch-${launch_uuid}.tmp`. |
64122
| restClientConfig | Optional | Not set | `axios` like http client [config](https://github.com/axios/axios#request-config). May contain `agent` property for configure [http(s)](https://nodejs.org/api/https.html#https_https_request_url_options_callback) client, and other client options eg. `timeout`. For debugging and displaying logs you can set `debug: true`. Use the `retry` property (number or [`axios-retry`](https://github.com/softonic/axios-retry#options) config) to customise automatic retries. |
65-
| launchUuidPrint | Optional | false | Whether to print the current launch UUID. |
66-
| launchUuidPrintOutput | Optional | 'STDOUT' | Launch UUID printing output. Possible values: 'STDOUT', 'STDERR', 'FILE', 'ENVIRONMENT'. Works only if `launchUuidPrint` set to `true`. File format: `rp-launch-uuid-${launch_uuid}.tmp`. Env variable: `RP_LAUNCH_UUID`. |
67-
| token | Deprecated | Not set | Use `apiKey` instead. |
123+
| launchUuidPrint | Optional | false | Whether to print the current launch UUID. |
124+
| launchUuidPrintOutput | Optional | 'STDOUT' | Launch UUID printing output. Possible values: 'STDOUT', 'STDERR', 'FILE', 'ENVIRONMENT'. Works only if `launchUuidPrint` set to `true`. File format: `rp-launch-uuid-${launch_uuid}.tmp`. Env variable: `RP_LAUNCH_UUID`. |
125+
| token | Deprecated | Not set | Use `apiKey` or `oauth` instead. |
68126

69127
## Asynchronous reporting
70128

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.4.2
1+
5.4.3-SNAPSHOT

0 commit comments

Comments
 (0)