Skip to content

Commit 25fa233

Browse files
committed
update readme with instruction for oauth library integration
1 parent 70a7b1c commit 25fa233

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

README.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ The **client-encryption-python** library provides a method you can use to integr
240240
from client_encryption.field_level_encryption_config import FieldLevelEncryptionConfig
241241
from client_encryption.api_encryption import add_encryption_layer
242242

243-
api_encryption.add_encryption_layer(api_client, config)
243+
add_encryption_layer(api_client, config)
244244
```
245245
This method will add the field level encryption in the generated OpenApi client, taking care of encrypting request and decrypting response payloads, but also of updating HTTP headers when needed, automatically, without manually calling `encrypt_payload()`/`decrypt_payload()` functions for each API request or response.
246246

@@ -281,7 +281,7 @@ To use it:
281281
# Create a new instance of the generated client
282282
api_client = ApiClient()
283283
# Enable field level encryption
284-
api_encryption.add_encryption_layer(api_client, config)
284+
add_encryption_layer(api_client, config)
285285
```
286286

287287
4. Use the `ApiClient` instance with the Field Level Encryption enabled:
@@ -290,11 +290,42 @@ To use it:
290290

291291
```python
292292
request_body = {...}
293-
response =MyServiceApi(api_client).do_some_action_post(body=request_body)
293+
response = MyServiceApi(api_client).do_some_action_post(body=request_body)
294294
# requests and responses will be automatically encrypted and decrypted
295295
# accordingly with the configuration object used
296296

297297
# ... use the (decrypted) response object here ...
298298
decrypted = response.json()
299299

300300
```
301+
302+
##### Usage of both `add_signing_layer` and `add_encryption_layer`:
303+
304+
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.
305+
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.
306+
307+
Example:
308+
309+
```python
310+
from oauth1.signer_interceptor import add_signing_layer
311+
from client_encryption.field_level_encryption_config import FieldLevelEncryptionConfig
312+
from client_encryption.api_encryption import add_encryption_layer
313+
from swagger_client.api_client import ApiClient # import generated swagger ApiClient
314+
315+
# Read the service configuration file
316+
config_file_path = "./config.json"
317+
config = FieldLevelEncryptionConfig(config_file_path)
318+
319+
# Create a new instance of the generated client
320+
api_client = ApiClient()
321+
322+
# Enable authentication
323+
add_signing_layer(api_client, key_file, key_password, consumer_key)
324+
325+
# Enable field level encryption
326+
add_encryption_layer(api_client, config)
327+
328+
response = MyServiceApi(api_client).do_some_action_post(body=request_body)
329+
decrypted = response.json()
330+
331+
```

0 commit comments

Comments
 (0)