Loading…

Basic Authentication calls the backend interface without login

The background interface of "apifm" can only be called after the administrator logs in. The interface request header needs to pass the x-token parameter, as shown in the figure: ![](https://dcdn.it120.cc/yuque/0/2021/png/572726/1624328487850-40cc1dc7-3413-4d99-a7fa-80c95ab135ef.png) The x-token needs to be obtained after the administrator logs in, but the x-token has a validity period, so the login interface needs to be called regularly to update the x-token, which is quite troublesome. In order to make it easier for you to call the backend interface on the server, you can use Basic Authentication to call the backend interface: #①View the backend merchant number and key ![](https://dcdn.it120.cc/yuque/0/2021/png/572726/1624328867889-e92de0d6-0226-4331-be5d-63a9695f42c2.png) If the merchant number here is: 12345678 If the merchant key here is: abcdefghijklmnopqrstuvwxyz #②GenerateAuthenticateString 1. Enter the merchant number and key above with **colon in english**Spliced together, for example: 12345678:abcdefghijklmnopqrstuvwxyzThe English colon in the middle cannot be missed! ! ! The English colon in the middle cannot be missed! ! ! The English colon in the middle cannot be missed! ! !2. Base64 encode the above string: There are some online base64 conversion websites you can use: [https://base64.us/](https://base64.us/) [http://tool.chinaz.com/tools/imgtobase/](http://tool.chinaz.com/tools/imgtobase/) [https://www.sojson.com/base64.html](https://www.sojson.com/base64.html) [http://tools.bugscaner.com/base64/](http://tools.bugscaner.com/base64/) [https://www.matools.com/base64](https://www.matools.com/base64) [https://www.bejson.com/ui/image2base64/](https://www.bejson.com/ui/image2base64/) As shown in the figure: ![](https://dcdn.it120.cc/yuque/0/2021/png/572726/1624329824867-27d7791a-0c19-4778-898e-a137d447e698.png) 3. Get encoding key: **MTIzNDU2Nzg6YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=** # ③ Call interfaceChange the x-token of the request header to Authorization The content is **Basic MTIzNDU2Nzg6YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=** **** **"Basic" Don't miss this one! ! !** **"Basic" Don't miss this one! ! !** **"Basic" Don't miss this one! ! !** **** **As shown below:** **** ![](https://dcdn.it120.cc/yuque/0/2021/png/572726/1624330039324-4c2b5902-d7d1-4e3f-8022-acd8fb4c0b6b.png)