Skip to content

Commit c03f452

Browse files
committed
Authorization header topic assed in webservice doc
1 parent 8a8c3ae commit c03f452

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

docs/webservice/basic-topics.md

+29-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,29 @@ We recomend you to use API clients like **Postman** or **Insomnia** to test/call
4848

4949
**_As you can see that no authentication process is required to access the APIs. So you need to be very careful with you access key rights._**
5050

51+
### Authorization header
52+
You can use Authorization header to access your APIs. In this method, a **base64_encode compute of your user:password couple** is used in place of exposing the API key directly. In QloApps API, user with empty password is used.
53+
54+
To compute the authorization key, you have to follow below code:
55+
56+
```php
57+
<?php
58+
$apiKey = `MNBDHALDK122DA879ADAD12ASKSK12W3`;
59+
// Encode and you can use the value in your request header
60+
$authorizationKey = base64_encode($apiKey . ':'); // TU5CREhBTERLMTIyREE4NzlBREFEMTJBU0tTSzEyVzM6
61+
```
62+
63+
#### Key|Value for Authorization header
64+
65+
| Key | Value |
66+
| :--- | :--- |
67+
| Authorization | Basic TU5CREhBTERLMTIyREE4NzlBREFEMTJBU0tTSzEyVzM6 |
68+
69+
*Here Value for the Authorization key is = **base64_encode($apiKey . ':')***
70+
71+
It is recommended to **use API clients such as Postman** for API testing. It is easier to switch with HTTP methods and to set request parameters and headers through this.
72+
73+
5174
### Learn to use webservice API
5275

5376
#### Resource description
@@ -203,5 +226,10 @@ Example:
203226
GET /api/ HTTP/1.1
204227
Host: example.com
205228
Output-Format: JSON
206-
Authorization: Basic VUNDTExROU4yQVJTSFdDWExUNzRLVUtTU0szNEJGS1g6
229+
Authorization: Basic TU5CREhBTERLMTIyREE4NzlBREFEMTJBU0tTSzEyVzM6
207230
```
231+
---
232+
233+
**NOTE**: In the above example, the API key is encoded with base64_encode() for use in headers. Visit [Authorization header](./basic-topics.md#authorization-header) for detail.
234+
235+
---

0 commit comments

Comments
 (0)