You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 13, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: docs/core-concepts/authorization-authentication/index.md
+24-20Lines changed: 24 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@ keywords:
12
12
- deriv-authorization
13
13
description: deriv api authentication and authorization
14
14
---
15
+
15
16
Without authentication and authorization you'll only get access to roughly half of our API calls and features. for example in order to buy contracts or utilize the `Copy Trading` features your users must be authenticated and authorized by our **OAuth** provider and **Websocket Server**.
16
17
17
18
## Before we start
@@ -20,12 +21,12 @@ You have to make sure you have all the requirements mentioned bellow to continue
20
21
21
22
### Requirements
22
23
23
-
1. Deriv Account
24
+
1. Deriv Account
24
25
2. Deriv API Token with the appropriate access level
25
-
3. Deriv App ID
26
+
3. Deriv App ID
26
27
27
28
:::note
28
-
Please refer to [Setting up a Deriv Application](docs/setting-up-a-deriv-application) for detailed instruction how to create Deriv API token and Applications
29
+
Please refer to [Setting up a Deriv Application](/docs/setting-up-a-deriv-application.md) for detailed instruction how to create Deriv API token and Applications
29
30
:::
30
31
31
32
### API Token
@@ -54,15 +55,13 @@ For more information on OAuth2, visit [this guide](https://aaronparecki.com/oau
54
55
55
56
Here is the visual representation of how the OAuth authorization connection works:
In order to Authenticate your user, specify the URL that will be used as the OAuth Redirect URL on the [Dashboard](/dashboard) page, **Register application** tab in the **OAuth details** fields and then Add a login button on your website or app and direct users to **`https://oauth.binary.com/oauth2/authorize?app_id=your_app_id`** where your_app_id is the ID of your app.
Once a user signs up / signs in, they will be redirected to the URL that you entered as the Redirect URL. This URL will have arguments added to it with the user's session tokens, and will look similar to this:
68
67
@@ -71,28 +70,32 @@ Once a user signs up / signs in, they will be redirected to the URL that you ent
71
70
## Authorization Process
72
71
73
72
The query params in the redirect URL are the user's accounts and their related session tokens. you can map the query params to an array like so:
73
+
74
74
```js
75
75
constuser_accounts= [
76
-
{
77
-
account:"cr799393",
78
-
token:"a1-f7pnteezo4jzhpxclctizt27hyeot",
79
-
currency:"usd"
80
-
},
81
-
{
82
-
account:"vrtc1859315",
83
-
token:"a1clwe3vfuuus5kraceykdsoqm4snfq",
84
-
currency:"usd"
85
-
},
86
-
]
76
+
{
77
+
account:'cr799393',
78
+
token:'a1-f7pnteezo4jzhpxclctizt27hyeot',
79
+
currency:'usd',
80
+
},
81
+
{
82
+
account:'vrtc1859315',
83
+
token:'a1clwe3vfuuus5kraceykdsoqm4snfq',
84
+
currency:'usd',
85
+
},
86
+
];
87
87
```
88
-
To authorize the user, based on the user's **Selected** account, call the [authorize](https://api.deriv.com/api-explorer#authorize) API call with the user's **Selected** account **Session Token**:
88
+
89
+
To authorize the user, based on the user's **Selected** account, call the [authorize](https://api.deriv.com/api-explorer#authorize) API call with the user's **Selected** account **Session Token**:
90
+
89
91
```js
90
92
{
91
93
"authorize":"a1-f7pnteezo4jzhpxclctizt27hyeot"
92
94
}
93
95
```
94
96
95
97
The response for the `authorize` call would be an object like so:
98
+
96
99
```js
97
100
{
98
101
"account_list": [
@@ -146,4 +149,5 @@ The response for the `authorize` call would be an object like so:
146
149
"user_id":12345678
147
150
}
148
151
```
149
-
Now user is authorized and you use Deriv API calls on behalf of the account.
152
+
153
+
Now user is authorized and you use Deriv API calls on behalf of the account.
0 commit comments