Skip to content

Commit 2182744

Browse files
authored
Merge pull request #13 from getyoti/Removing-Old-Buttons
[SDK-165]: Removed login button helper functions from Example project, tidied up READMEs
2 parents 8a10d67 + 171dfd9 commit 2182744

File tree

18 files changed

+62
-202
lines changed

18 files changed

+62
-202
lines changed

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,17 @@ import "yoti_python_sdk"
9191

9292
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).
9393

94-
The following variables are then required for the SDK to work:
94+
The variables required for the SDK to work are found in the tabs on your Yoti application's settings page ([Yoti Dashboard](https://www.yoti.com/dashboard/)). These are:
9595

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)
96+
* **`YOTI_APPLICATION_ID`** - This is used to configure the [Yoti Login Button](https://www.yoti.com/developers/documentation/#2-front-end-integration).
97+
* **`YOTI_CLIENT_SDK_ID`** - This 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.
98+
* **`YOTI_KEY_FILE_PATH`** - This is the path to the application .pem file, we recommend keeping your .pem file outside of your repository. It can be downloaded only once from the Keys tab in your Yoti Dashboard. (e.g. /home/user/.ssh/access-security.pem).
9899

99-
Please do not open the pem file as this might corrupt the key and you will need to create a new application.
100+
**Please do not open the pem file** as this might corrupt the key and you will need to create a new application.
100101

101-
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).
102+
One way to configure these environment variables is to use an .env file. There are `.env.example` files supplied in the [Django](/examples/yoti_example_django/yoti_example/.env.example) and [Flask](/examples/yoti_example_flask/.env.example) example projects, which you can rename to `.env` and enter your settings into this file.
103103

104-
Keeping your settings and access keys outside your repository is highly recommended.
105-
106-
### Example
104+
### Example Initialisation
107105

108106
```python
109107
from yoti_python_sdk import Client

examples/yoti_example_django/yoti_example/templates/index.html

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,13 @@
1111
<!-- Your website content -->
1212

1313
<!-- This span will create the Yoti button -->
14-
<span
15-
data-yoti-application-id="{{ app_id }}"
16-
data-size="small"
17-
>
14+
<span data-yoti-application-id="{{app_id}}">
1815
Log in with Yoti
1916
</span>
2017

21-
<!-- This script snippet will also be required in your HTML body during the early pilot period -->
18+
<!-- This script snippet will also be required in your HTML body -->
2219
<script>
23-
_ybg.config.service = 'https://www.yoti.com/connect/';
24-
_ybg.init();
20+
_ybg.init()
2521
</script>
2622
</body>
2723
</html>

examples/yoti_example_django/yoti_example/views.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from binascii import a2b_base64
2+
from os.path import join, dirname
23

34
from django.views.generic import TemplateView
4-
5-
from os.path import join, dirname
65
from dotenv import load_dotenv
76

87
dotenv_path = join(dirname(__file__), '.env')

examples/yoti_example_flask/templates/index.html

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,13 @@
1111
<!-- Your website content -->
1212

1313
<!-- This span will create the Yoti button -->
14-
<span
15-
data-yoti-application-id="{{ app_id }}"
16-
data-size="small"
17-
>
14+
<span data-yoti-application-id="{{app_id}}">
1815
Log in with Yoti
1916
</span>
2017

21-
<!-- This script snippet will also be required in your HTML body during the early pilot period -->
18+
<!-- This script snippet will also be required in your HTML body -->
2219
<script>
23-
_ybg.config.service = 'https://www.yoti.com/connect/';
24-
_ybg.init();
20+
_ybg.init()
2521
</script>
2622
</body>
2723
</html>

plugins/django_yoti/README.md

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ INSTALLED_APPS = [
1717
]
1818
```
1919

20-
* Django Yoti plugin provides the following template context vars:
20+
* Django Yoti plugin provides the following template context var:
2121
- `yoti_application_id`
22-
- `yoti_login_button_*`
2322

2423
* If you're using a Django template backend that supports context processors
2524
like default DTL (Django Template Language) and want to use context tags
26-
inside your template (e.g. `{{ yoti_login_button_*}}`), then you should
25+
inside your template (e.g. `{{yoti_application_id}}`), then you should
2726
include `django_yoti`'s context processors into your templates
2827
configuration like this:
2928
```python
@@ -51,9 +50,17 @@ def some_view(request):
5150
return render(request, 'index.html', yoti_context)
5251
```
5352

54-
* And then use the following settings to configure the plugin:
53+
The variables required for the SDK to work are found in the tabs on your Yoti application's settings page ([Yoti Dashboard](https://www.yoti.com/dashboard/)). These are:
5554

55+
* **`YOTI_APPLICATION_ID`** - This is used to configure the [Yoti Login Button](https://www.yoti.com/developers/documentation/#2-front-end-integration).
56+
* **`YOTI_CLIENT_SDK_ID`** - This 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.
57+
* **`YOTI_KEY_FILE_PATH`** - This is the path to the application .pem file, we recommend keeping your .pem file outside of your repository. It can be downloaded only once from the Keys tab in your Yoti Dashboard. (e.g. /home/user/.ssh/access-security.pem).
5658

59+
**Please do not open the pem file** as this might corrupt the key and you will need to create a new application.
60+
61+
One way to configure these environment variables is to use an .env file. There are `.env.example` files supplied in the [Django](/examples/yoti_example_django/yoti_example/.env.example) and [Flask](/examples/yoti_example_flask/.env.example) example projects, which you can rename to `.env` and enter your settings into this file.
62+
63+
Alternatively you could define these settings in the `settings.py` file like this:
5764
```python
5865
# your_django_project/settings.py
5966

@@ -66,21 +73,6 @@ YOTI = {
6673
...
6774
}
6875
```
69-
* **`YOTI_APPLICATION_ID`** - **required**, *can be also set by env variable with the same name*<br>
70-
Your Yoti application's ID, found under the `INTEGRATIONS` tab of your
71-
Yoti application's settings page ([Yoti Dashboard](https://www.yoti.com/dashboard/)).<br>
72-
It is used to configure the [Yoti Login Button](https://www.yoti.com/developers/#login-button-setup).<br>
73-
Example: `ca84f68b-1b48-458b-96bf-963868edc8b6`
74-
75-
* **`YOTI_CLIENT_SDK_ID`** - **required**, *can be also set by env variable with the same name*<br>
76-
Your Yoti application's SDK ID, found under the `INTEGRATIONS` tab of your
77-
Yoti application's settings page ([Yoti Dashboard](https://www.yoti.com/dashboard/)).<br>
78-
Example: `39aef70a-89d6-4644-a687-b3e891613da6`
79-
80-
* **`YOTI_KEY_FILE_PATH`** - **required**, *can be also set by env variable with the same name*<br>
81-
The full path to your private key downloaded from your Yoti application's
82-
settings page under the `KEYS` tab ([Yoti Dashboard](https://www.yoti.com/dashboard/)).<br>
83-
Example: `/home/user/.ssh/access-security.pem`
8476

8577
### Endpoints configuration ###
8678

@@ -106,7 +98,6 @@ YOTI = {
10698
...
10799
'YOTI_LOGIN_VIEW': '...',
108100
'YOTI_REDIRECT_TO': '...',
109-
'YOTI_LOGIN_BUTTON_LABEL': '...',
110101
}
111102
```
112103
* **`YOTI_LOGIN_VIEW`**<br>
@@ -159,13 +150,12 @@ Your Yoti application's callback URL should point to `your_site.com/yoti/auth`.
159150
## Using plugin ##
160151

161152
1. First you need to add a login button to some of your view's templates.
162-
- You can do it by using one of the predefined login buttons:
163-
```
164-
{{ yoti_login_button_sm }}
165-
{{ yoti_login_button_md }}
166-
{{ yoti_login_button_lg }}
153+
- You can do it by using the predefined login button:
154+
```HTML
155+
<span data-yoti-application-id="{{app_id}}">
156+
Log in with Yoti
157+
</span>
167158
```
168-
- or with a default one `{{ yoti_login_button }}`<br>
169159

170160
By clicking this button, user will be redirected to the Yoti Authentication page.
171161

plugins/django_yoti/django_yoti/context_processors.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
1-
from .login_button import get_login_button_html
21
from .settings import YOTI_APPLICATION_ID
32

43

54
def yoti_context(request=None):
6-
context = login_button_context()
7-
context.update(application_context())
8-
return context
9-
10-
11-
def login_button_context():
12-
return {
13-
'yoti_login_button': get_login_button_html,
14-
'yoti_login_button_sm': get_login_button_html('small'),
15-
'yoti_login_button_md': get_login_button_html('medium'),
16-
'yoti_login_button_lg': get_login_button_html('large')
17-
}
5+
return application_context()
186

197

208
def application_context():

plugins/django_yoti/django_yoti/login_button.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

plugins/django_yoti/django_yoti/settings.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@ def _get_parameter(name, required=True):
2020

2121
YOTI_REDIRECT_TO = GLOBAL_YOTI_SETTINGS.get('YOTI_REDIRECT_TO', 'yoti_profile')
2222
YOTI_LOGIN_VIEW = GLOBAL_YOTI_SETTINGS.get('YOTI_LOGIN_VIEW', 'yoti_login')
23-
YOTI_LOGIN_BUTTON_LABEL = GLOBAL_YOTI_SETTINGS.get('YOTI_LOGIN_BUTTON_LABEL',
24-
'Log in with Yoti')
2523

2624
__all__ = [
2725
'YOTI_APPLICATION_ID',
2826
'YOTI_CLIENT_SDK_ID',
2927
'YOTI_KEY_FILE_PATH',
3028
'YOTI_REDIRECT_TO',
3129
'YOTI_LOGIN_VIEW',
32-
'YOTI_LOGIN_BUTTON_LABEL',
3330
]

plugins/django_yoti/django_yoti/templates/login_button.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

plugins/django_yoti/django_yoti/templates/yoti_login.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
<!-- Your website content -->
1212

1313
<!-- This span will create the Yoti button -->
14-
<div>Button: {{ yoti_login_button }}</div>
14+
<span data-yoti-application-id="{{app_id}}">
15+
Log in with Yoti
16+
</span>
1517

16-
<!-- This script snippet will also be required in your HTML body during the early pilot period -->
18+
<!-- This script snippet will also be required in your HTML body -->
1719
<script>
18-
_ybg.config.service = 'https://www.yoti.com/connect/';
19-
_ybg.init();
20+
_ybg.init()
2021
</script>
2122
</body>
2223
</html>

0 commit comments

Comments
 (0)