Skip to content

Commit f501ae0

Browse files
committed
doc: add example with authentication
Thank you, @FedorSelitsky, Fedor Selitsky <[email protected]>! Addresses #22
1 parent eeb6f57 commit f501ae0

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

USAGE.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,32 @@ SERVICE_URL = 'http://services.odata.org/V2/Northwind/Northwind.svc/'
1212
client = pyodata.Client(SERVICE_URL, requests.Session())
1313
```
1414

15+
### Get the service proxy client for an OData service requiring authentication
16+
17+
Let's assume you need to work with a service at
18+
the URL `https://odata.example.com/Secret.svc` and User ID is 'MyUser' with
19+
the password 'MyPassword'.
20+
21+
PyOData expects that the used HTTP library will take care about this task.
22+
23+
In this example we configure
24+
[Session](https://2.python-requests.org/en/master/user/advanced/#session-objects) of
25+
[python-requests](https://2.python-requests.org/en/master/) to handle
26+
user authentication.
27+
28+
```python
29+
import requests
30+
import pyodata
31+
32+
SERVICE_URL = 'https://odata.example.com/Secret.svc'
33+
34+
session = requests.Session()
35+
session.auth = ('MyUser', 'MyPassword')
36+
37+
# Create instance of OData client
38+
client = pyodata.Client(SERVICE_URL, session)
39+
```
40+
1541
### Get one entity identified by its key value
1642

1743
```python

0 commit comments

Comments
 (0)