Skip to content

Commit 59677a1

Browse files
committed
readme refactor
1 parent 25fa233 commit 59677a1

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ See also:
262262

263263
To use it:
264264

265-
1. Generate the OpenAPI client, as [above](#openapi-generator)
265+
1. Generate the [OpenAPI client](#openapi-generator)
266266

267267
2. Import the **mastercard-client-encryption** module and the generated swagger ApiClient
268268

@@ -304,27 +304,38 @@ To use it:
304304
In order to use both signing and encryption layers, a defined order is required as signing library should calculate the hash of the encrypted payload.
305305
According to the above the signing layer must be applied first in order to work as inner layer. The outer layer - encryption - will be executed first, providing the signing layer the encrypted payload to sign.
306306

307-
Example:
307+
1. Generate the [OpenAPI client](#openapi-generator)
308+
309+
2. Import both **mastercard-oauth1-signer** and **mastercard-client-encryption** modules and the generated swagger ApiClient
308310

309311
```python
310312
from oauth1.signer_interceptor import add_signing_layer
311313
from client_encryption.field_level_encryption_config import FieldLevelEncryptionConfig
312314
from client_encryption.api_encryption import add_encryption_layer
313315
from swagger_client.api_client import ApiClient # import generated swagger ApiClient
316+
```
314317

315-
# Read the service configuration file
316-
config_file_path = "./config.json"
317-
config = FieldLevelEncryptionConfig(config_file_path)
318-
318+
3. Add the authentication layer to the generated client:
319+
```python
319320
# Create a new instance of the generated client
320321
api_client = ApiClient()
321322

322323
# Enable authentication
323324
add_signing_layer(api_client, key_file, key_password, consumer_key)
325+
```
326+
327+
4. Then add the field level encryption layer:
328+
```python
329+
# Read the service configuration file
330+
config_file_path = "./config.json"
331+
config = FieldLevelEncryptionConfig(config_file_path)
324332

325333
# Enable field level encryption
326334
add_encryption_layer(api_client, config)
327-
335+
```
336+
337+
5. Use the `ApiClient` instance with Authentication and Field Level Encryption both enabled:
338+
```python
328339
response = MyServiceApi(api_client).do_some_action_post(body=request_body)
329340
decrypted = response.json()
330341

0 commit comments

Comments
 (0)