Skip to content

Commit 7dd1934

Browse files
author
Vasile Zaremba
committed
Improve Readme
1 parent fa96ecb commit 7dd1934

File tree

2 files changed

+82
-58
lines changed

2 files changed

+82
-58
lines changed

README.md

Lines changed: 82 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ Yoti SDK carries out for you steps 6, 7 and the profile decryption in step 8.
4747

4848
![alt text](login_flow.png "Login flow")
4949

50-
5150
Yoti also allows you to enable user details verification from your mobile app by means of the Android (TBA) and iOS (TBA) SDKs. In that scenario, your Yoti-enabled mobile app is playing both the role of the browser and the Yoti app. Your back-end doesn't need to handle these cases in a significantly different way. You might just decide to handle the `User-Agent` header in order to provide different responses for desktop and mobile clients.
5251

5352
## References
@@ -64,75 +63,90 @@ Yoti also allows you to enable user details verification from your mobile app by
6463

6564
## Requirements
6665

67-
This SDK works with Python 2.6+ and Python 3.3+ .
66+
This SDK works with Python 2.6+ and Python 3.3+.
6867

6968
## Installing the SDK
7069

7170
To import the Yoti SDK inside your project, simply run the following command from your terminal:
7271

72+
```shell
73+
$ pip install yoti-python-sdk
7374
```
74-
$ pip install yoti-python-sdk
75-
```
76-
77-
Both example applications utilise the env variables described above, make sure they are accessible.
78-
* Installing dependencies: `pip install -e .[examples]`
79-
80-
Flask:
81-
82-
* Run `python examples/yoti_example_flask/app.py`
83-
84-
Djano:
85-
86-
1. Apply migrations before the first start by running:<br>
87-
`python examples/yoti_example_django/manage.py migrate`
88-
1. Run: `python examples/yoti_example_django/manage.py runserver 0.0.0.0:5000`
8975

9076
## SDK Project import
9177

9278
You can reference the project URL by adding the following import:
9379

94-
```
80+
```python
9581
import "yoti_python_sdk"
9682
```
9783

98-
Run your project but please make sure you have all the correct requirements:
84+
## Configuration
9985

100-
1. Install dependencies: `pip install -r requirements.txt`
101-
2. Install the SDK: `python setup.py develop`
102-
3. Execute in the main project dir: `py.test`
103-
4. To execute integration tests run: `py.test -c pytest_integration.ini`
86+
After creating your application on the [Yoti Dashboard](https://www.yoti.com/dashboard/), you need to download the `.PEM` key and save it *outside* the repo (keep it private).
10487

105-
## Configuration
88+
The following variables are then required for the SDK to work:
10689

107-
The YotiClient is the SDK entry point. To initialise it you need include the following snippet inside your endpoint initialisation section:
90+
* `YOTI_CLIENT_SDK_ID` - is the SDK identifier generated by Yoti Dashboard in the Key tab when you create your app. Note this is not your Application Identifier which is needed by your client-side code
91+
* `YOTI_KEY_FILE_PATH` - is the path to the application pem file. It can be downloaded only once from the Keys tab in your Yoti Dashboard. (e.g. /home/user/.ssh/access-security.pem)
10892

109-
```
93+
Please do not open the pem file as this might corrupt the key and you will need to create a new application.
94+
95+
The following env variables are additionally used to configure your backend:
96+
* `YOTI_APPLICATION_ID` - found on the Integrations settings page, used to configure the [Yoti Login Button](https://www.yoti.com/developers/#login-button-setup).
97+
98+
Keeping your settings and access keys outside your repository is highly recommended.
99+
100+
### Example
101+
102+
```python
110103
from yoti_python_sdk import Client
111104
@app.route('/profile')
112105
def auth():
113106
client = Client(YOTI_CLIENT_SDK_ID, YOTI_KEY_FILE_PATH)
114107
activity_details = client.get_activity_details(request.args['token'])
115108
```
116-
Where:
117-
- `SDK_ID` is the SDK identifier generated by Yoti Dashboard in the Key tab when you create your app. Note this is not your Application Identifier which is needed by your client-side code.
118-
119-
- `YOTI_KEY_FILE_PATH` is the path to the application pem file. It can be downloaded only once from the Keys tab in your Yoti Dashboard.
120-
121-
Please do not open the pem file as this might corrupt the key and you will need to create a new application.
122-
123-
Keeping your settings and access keys outside your repository is highly recommended.
124109

125110
## Profile Retrieval
126111

127112
When your application receives a token via the exposed endpoint (it will be assigned to a query string parameter named `token`), you can easily retrieve the user profile by adding the following to your endpoint handler:
128113

129-
```
114+
```python
130115
activity_details = client.get_activity_details(request.args['token'])
131116
user_profile = activity_details.user_profile
132117
return render_template('profile.html',
133118
**user_profile)
134-
```
135-
119+
120+
```
121+
122+
## Running the examples
123+
124+
Both example applications utilise the env variables described above, make sure they are accessible.
125+
126+
* Installing dependencies: `pip install -e .[examples]`
127+
128+
### Flask:
129+
130+
* Run `python examples/yoti_example_flask/app.py`
131+
132+
### Django:
133+
134+
1. Apply migrations before the first start by running: `python examples/yoti_example_django/manage.py migrate`
135+
1. Run: `python examples/yoti_example_django/manage.py runserver 0.0.0.0:5000`
136+
137+
### Plugins ###
138+
139+
Plugins for both Django and Flask are in the `plugins/` dir. Their purpose is to make it as easy as possible to use the Yoti SDK with those frameworks. See their respective `README` files for details.
140+
141+
## Running the tests
142+
143+
Run your project but please make sure you have all the correct requirements:
144+
145+
1. Install dependencies: `pip install -r requirements.txt`
146+
2. Install the SDK: `python setup.py develop`
147+
3. Execute in the main project dir: `py.test`
148+
4. To execute integration tests run: `py.test -c pytest_integration.ini`
149+
136150
## API Coverage
137151

138152
* Activity Details
@@ -147,16 +161,8 @@ user_profile = activity_details.user_profile
147161
* [X] Address `postal_address`
148162
* [X] Gender `gender`
149163
* [X] Nationality `nationality`
164+
* [X]
150165

151-
## Support
152-
153-
For any questions or support please email [[email protected]](mailto:[email protected]).
154-
Please provide the following the get you up and working as quick as possible:
155-
156-
- Computer Type
157-
- OS Version
158-
- Version of Python being used
159-
- Screenshot
160166

161167
## Version Support
162168
### Testing on multiple Python versions ###
@@ -177,23 +183,27 @@ test suite on Python 2.6 (2.6.9 in our case, as installed with `pyenv`).
177183

178184
To install all the Python versions this SDK has been tested against run:
179185

180-
$ for version in 2.6.9 2.7.12 3.3.6 3.4.5 3.5.2 3.6.0b3; do pyenv install $version; done
186+
```shell
187+
$ for version in 2.6.9 2.7.12 3.3.6 3.4.5 3.5.2 3.6.0b3; do pyenv install $version; done
188+
```
181189

182-
activate the installed interpreters (execute in this directory):
190+
Sctivate the installed interpreters (execute in this directory):
183191

184-
$ pyenv local 2.6.9 2.7.12 3.3.6 3.4.5 3.5.2 3.6.0b3
192+
```shell
193+
$ pyenv local 2.6.9 2.7.12 3.3.6 3.4.5 3.5.2 3.6.0b3
194+
```
185195

186-
run the tests:
196+
Run the tests:
187197

188-
$ tox
198+
```shell
199+
$ tox
200+
```
189201

190202
#### Tox Common Issues ####
191203

192204
Supporting multiple Python versions with dependencies, often requiring compilation, is not without issues.
193205

194-
For Python versions that do not provide binary wheels for `cryptography`, it
195-
will have to be compiled. This will be done automatically, however you may
196-
need to install development headers of `openssl`.
206+
For Python versions that do not provide binary wheels for `cryptography`, it will have to be compiled. This will be done automatically, however, you may need to install development headers of `openssl`.
197207

198208
##### On Debian-based systems #####
199209

@@ -203,15 +213,29 @@ Install `openssl` headers with `apt-get install openssl-dev`
203213

204214
Install `openssl` headers using [homebrew](http://brew.sh/): `brew install openssl`
205215

206-
Install xcode command line tools so we have access to a C compiler and common libs:
216+
Install Xcode command line tools so we have access to a C compiler and common libs:
207217

208-
xcode-select --install
218+
```shell
219+
$ xcode-select --install
220+
```
209221

210222
See [building cryptography on OS X](https://cryptography.io/en/latest/installation/#building-cryptography-on-os-x)
211223

212224

213225
For Python 2.6 and 2.7 you *might* have to install them via `pyenv` with specific unicode code point settings:
214226

215-
PYTHON_CONFIGURE_OPTS="--enable-unicode=ucs2" pyenv install <python version>
227+
```
228+
PYTHON_CONFIGURE_OPTS="--enable-unicode=ucs2" pyenv install <python version>
229+
```
230+
231+
To avoid `cffi` errors related to unicode see: [cffi ucs2 vs ucs4](http://cffi.readthedocs.io/en/latest/installation.html#linux-and-os-x-ucs2-versus-ucs4)
216232

217-
to avoid `cffi` errors related to unicode see: [cffi ucs2 vs ucs4](http://cffi.readthedocs.io/en/latest/installation.html#linux-and-os-x-ucs2-versus-ucs4)
233+
## Support
234+
235+
For any questions or support please email [[email protected]](mailto:[email protected]).
236+
Please provide the following the get you up and working as quick as possible:
237+
238+
- Computer Type
239+
- OS Version
240+
- Version of Python being used
241+
- Screenshot

login_flow.png

102 KB
Loading

0 commit comments

Comments
 (0)