Skip to content

Commit cf88cd8

Browse files
author
Vasile Zaremba
authored
Merge pull request #3 from KiranBali/patch-1
Update README.md
2 parents 8a99500 + cd58a9a commit cf88cd8

File tree

2 files changed

+166
-53
lines changed

2 files changed

+166
-53
lines changed

README.md

Lines changed: 166 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,176 @@
11
# Yoti Python SDK #
22

3-
This package integrates your Python back-end with [Yoti](https://www.yoti.com/) allowing you to
4-
securely verify users' identities.
3+
Welcome to the Yoti Python SDK. This repo contains the tools and step by step instructions you need to quickly integrate your Python back-end with Yoti so that your users can share their identity details with your application in a secure and trusted way.
54

6-
## Example ##
5+
## Table of Contents
76

8-
from yoti_python_sdk import Client
7+
1) [An Architectural view](#an-architectural-view) -
8+
High level overview of integration
99

10-
@app.route('/callback')
11-
def callback():
12-
client = Client(YOTI_CLIENT_SDK_ID, YOTI_KEY_FILE_PATH)
13-
activity_details = client.get_activity_details(request.args['token'])
14-
return activity_details.user_profile
10+
2) [References](#references)-
11+
Guides before you start
1512

16-
For more details and working [Flask](http://flask.pocoo.org/) and [Django](https://www.djangoproject.com/)
17-
applications see [examples/](https://github.com/getyoti/yoti-python-sdk/tree/master/examples).
13+
3) [Requirements](#requirements)-
14+
Everything you need to get started
1815

16+
4) [Installing the SDK](#installing-the-sdk)-
17+
How to install our SDK
1918

20-
## The Flow ##
19+
5) [SDK Project import](#sdk-project-import)-
20+
How to install the SDK to your project
2121

22-
Assuming you created an application and chose `/callback` as your application's callback on [Yoti Dashboard](https://www.yoti.com/dashboard/),
23-
this endpoint will receive a `token` from Yoti API each time user wishes to share information with you (see the example above).
24-
This token, encrypted with the private key from `.PEM` container, will be used to send a request to Yoti
25-
for user's profile details. That's all folks!
22+
6) [Configuration](#configuration)-
23+
Entry point explanation
2624

27-
For details see [Yoti Developers Docs](https://www.yoti.com/developers/).
25+
7) [Profile Retrieval](#profile-retrieval)-
26+
How to retrieve a Yoti profile using the token
2827

29-
## Installation ##
28+
8) [Running the examples](#running-the-examples)-
29+
How to retrieve a Yoti profile using the token
3030

31-
$ pip install yoti-python-sdk
31+
9) [Running the tests](#running-the-tests)-
32+
How to retrieve a Yoti profile using the token
3233

33-
This SDK works with Python 2.6+ and Python 3.3+ .
34+
10) [API Coverage](#api-coverage)-
35+
Attributes defined
3436

35-
## Configuration ##
37+
11) [Running the tests](running-the-tests)-
38+
Running tests for SDK example
3639

37-
After creating your application on the [Yoti Dashboard](https://www.yoti.com/dashboard/), you need to download
38-
the `.PEM` key and save it *outside* the repo (keep it private).
40+
12) [Support](#support)-
41+
Please feel free to reach out
3942

40-
The following env variables are then required for the SDK to work:
43+
13) [Version Support](version-support) -
44+
Extra information on ensuring correct version of Python is being used
4145

42-
* `YOTI_CLIENT_SDK_ID` - found on the Integrations settings page
43-
* `YOTI_KEY_FILE_PATH` - the full path to your private key downloaded from the Keys settings page (e.g. /home/user/.ssh/access-security.pem)
46+
## An Architectural view
47+
48+
Before you start your integration, here is a bit of background on how the integration works. To integrate your application with Yoti, your back-end must expose a GET endpoint that Yoti will use to forward tokens.
49+
The endpoint can be configured in the Yoti Dashboard when you create/update your application. For more information on how to create an application please check our [developer page](https://www.yoti.com/developers/documentation/#login-button-setup).
50+
51+
The image below shows how your application back-end and Yoti integrate into the context of a Login flow.
52+
Yoti SDK carries out for you steps 6, 7 and the profile decryption in step 8.
53+
54+
![alt text](login_flow.png "Login flow")
55+
56+
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.
57+
58+
## References
59+
60+
* [AES-256 symmetric encryption][]
61+
* [RSA pkcs asymmetric encryption][]
62+
* [Protocol buffers][]
63+
* [Base64 data][]
64+
65+
[AES-256 symmetric encryption]: https://en.wikipedia.org/wiki/Advanced_Encryption_Standard
66+
[RSA pkcs asymmetric encryption]: https://en.wikipedia.org/wiki/RSA_(cryptosystem)
67+
[Protocol buffers]: https://en.wikipedia.org/wiki/Protocol_Buffers
68+
[Base64 data]: https://en.wikipedia.org/wiki/Base64
69+
70+
## Requirements
71+
72+
This SDK works with Python 2.6+ and Python 3.3+.
73+
74+
## Installing the SDK
75+
76+
To import the Yoti SDK inside your project, simply run the following command from your terminal:
77+
78+
```shell
79+
$ pip install yoti-python-sdk
80+
```
81+
82+
## SDK Project import
83+
84+
You can reference the project URL by adding the following import:
85+
86+
```python
87+
import "yoti_python_sdk"
88+
```
89+
90+
## Configuration
91+
92+
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).
93+
94+
The following variables are then required for the SDK to work:
95+
96+
* `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
97+
* `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)
98+
99+
Please do not open the pem file as this might corrupt the key and you will need to create a new application.
44100

45101
The following env variables are additionally used to configure your backend:
102+
* `YOTI_APPLICATION_ID` - found on the Integrations settings page, used to configure the [Yoti Login Button](https://www.yoti.com/developers/#login-button-setup).
103+
104+
Keeping your settings and access keys outside your repository is highly recommended.
105+
106+
### Example
107+
108+
```python
109+
from yoti_python_sdk import Client
110+
@app.route('/profile')
111+
def auth():
112+
client = Client(YOTI_CLIENT_SDK_ID, YOTI_KEY_FILE_PATH)
113+
activity_details = client.get_activity_details(request.args['token'])
114+
```
115+
116+
## Profile Retrieval
117+
118+
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:
46119

47-
* `YOTI_APPLICATION_ID` - found on the Integrations settings page, used to configure the [Yoti Login Button](https://www.yoti.com/developers/#login-button-setup)
120+
```python
121+
activity_details = client.get_activity_details(request.args['token'])
122+
user_profile = activity_details.user_profile
123+
return render_template('profile.html',
124+
**user_profile)
48125

49-
## Examples ##
126+
```
127+
128+
## Running the examples
50129

51130
Both example applications utilise the env variables described above, make sure they are accessible.
52-
* Installing dependencies: `pip install -e .[examples]`
53131

132+
* Installing dependencies: `pip install -e .[examples]`
54133

55-
### Flask ###
134+
### Flask:
56135

57136
* Run `python examples/yoti_example_flask/app.py`
58137

59-
### Django ###
138+
### Django:
60139

61-
1. Apply migrations before the first start by running:<br>
62-
`python examples/yoti_example_django/manage.py migrate`
140+
1. Apply migrations before the first start by running: `python examples/yoti_example_django/manage.py migrate`
63141
1. Run: `python examples/yoti_example_django/manage.py runserver 0.0.0.0:5000`
64142

65-
66143
### Plugins ###
67144

68-
Plugins for both Django and Flask are in the `plugins/` dir. Their purpose is to make it as easy as possible to use
69-
Yoti SDK with those frameworks. See their respective `README`'s for details.
145+
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.
70146

147+
## Running the tests
71148

72-
## Executing tests ##
149+
Run your project but please make sure you have all the correct requirements:
73150

74151
1. Install dependencies: `pip install -r requirements.txt`
75-
1. Install the SDK: `python setup.py develop`
76-
1. Execute in the main project dir: `py.test`
77-
1. To execute integration tests run: `py.test -c pytest_integration.ini`
78-
152+
2. Install the SDK: `python setup.py develop`
153+
3. Execute in the main project dir: `py.test`
154+
4. To execute integration tests run: `py.test -c pytest_integration.ini`
155+
156+
## API Coverage
157+
158+
* Activity Details
159+
* [X] User ID `user_id`
160+
* [X] Profile
161+
* [X] Photo `selfie`
162+
* [X] Given Names `given_names`
163+
* [X] Family Name `family_name`
164+
* [X] Mobile Number `phone_number`
165+
* [X] Email address `email_address`
166+
* [X] Date of Birth `date_of_birth`
167+
* [X] Address `postal_address`
168+
* [X] Gender `gender`
169+
* [X] Nationality `nationality`
170+
* [X]
171+
172+
173+
## Version Support
79174
### Testing on multiple Python versions ###
80175

81176
Tests executed using [py.test](http://doc.pytest.org/en/latest/) use your default/virtualenv's Python interpreter.
@@ -94,23 +189,27 @@ test suite on Python 2.6 (2.6.9 in our case, as installed with `pyenv`).
94189

95190
To install all the Python versions this SDK has been tested against run:
96191

97-
$ 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
192+
```shell
193+
$ 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
194+
```
98195

99-
activate the installed interpreters (execute in this directory):
196+
Sctivate the installed interpreters (execute in this directory):
100197

101-
$ pyenv local 2.6.9 2.7.12 3.3.6 3.4.5 3.5.2 3.6.0b3
198+
```shell
199+
$ pyenv local 2.6.9 2.7.12 3.3.6 3.4.5 3.5.2 3.6.0b3
200+
```
102201

103-
run the tests:
202+
Run the tests:
104203

105-
$ tox
204+
```shell
205+
$ tox
206+
```
106207

107208
#### Tox Common Issues ####
108209

109210
Supporting multiple Python versions with dependencies, often requiring compilation, is not without issues.
110211

111-
For Python versions that do not provide binary wheels for `cryptography`, it
112-
will have to be compiled. This will be done automatically, however you may
113-
need to install development headers of `openssl`.
212+
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`.
114213

115214
##### On Debian-based systems #####
116215

@@ -120,15 +219,29 @@ Install `openssl` headers with `apt-get install openssl-dev`
120219

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

123-
Install xcode command line tools so we have access to a C compiler and common libs:
222+
Install Xcode command line tools so we have access to a C compiler and common libs:
124223

125-
xcode-select --install
224+
```shell
225+
$ xcode-select --install
226+
```
126227

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

129230

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

132-
PYTHON_CONFIGURE_OPTS="--enable-unicode=ucs2" pyenv install <python version>
233+
```
234+
PYTHON_CONFIGURE_OPTS="--enable-unicode=ucs2" pyenv install <python version>
235+
```
236+
237+
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)
238+
239+
## Support
240+
241+
For any questions or support please email [[email protected]](mailto:[email protected]).
242+
Please provide the following the get you up and working as quick as possible:
133243

134-
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)
244+
- Computer Type
245+
- OS Version
246+
- Version of Python being used
247+
- Screenshot

login_flow.png

102 KB
Loading

0 commit comments

Comments
 (0)