当前位置:网站首页>[208] API design based on accesstoken
[208] API design based on accesstoken
2022-06-28 16:32:00 【Milo mouth】
One 、 Illustrate with examples :
demand :
A、B The organization needs to call X The interface to the server , that X The server needs to provide an open Internet access interface .
analysis :
1、 Open platform providers X, Provide corresponding services for each cooperative organization appid、app_secret.
2、appid Is the only one. ( Can't change ), Indicates the corresponding third-party Cooperation Organization , Used to distinguish between different institutions .
3、app_secret Realize the encryption function in the transmission ( Secret key ), The secret key can be changed .
4、 Why? app_secret It can be changed ? Calling the interface requires appid+app_secret Generate corresponding access_token( Temporary ), If appid and app_secret Be leaked , Create security problems , If you find it leaked , You can regenerate a app_secret.
principle : Create a corresponding for each partner appid、app_secret, Generate corresponding access_token( The period of validity 2 Hours ), When calling the external network open interface , Must pass valid access_token.
Two 、 Development steps
1、 Use appid+app_secret Generate corresponding access_token
1. Get generated AppId and appSecret, And verify availability
2. Delete the previous accessToken
2.AppId and appSecret Ensure that the corresponding unique accessToken
Be careful : The second step above must ensure that in the same transaction
3. Go back to the latest accessToken
2、 Use accessToken Call the third-party interface
1. Get the corresponding accessToken
2. Use AccessToken Inquire about redis Corresponding value(appId)
3. If you don't get the corresponding appid, Directly return the error prompt
4. If you can get the corresponding appid, Use appid Query corresponding APP Information
5. Use appId Query the database app Information , obtain is_flag state , If 1, The interface... Cannot be called , Otherwise execute normally
6. Directly call the interface business
边栏推荐
- What are the most powerful small and medium-sized companies in Beijing?
- 【杂谈】2021/01/31 哦豁
- WPF 视频硬解码渲染播放(无空域)(支持4K、8K、高帧率视频)
- The first place on the list - brake by wire "new cycle", the market competitiveness of local suppliers is TOP10
- O & M - unified gateway is very necessary
- Lenet5 training model of convolutional neural network for machine learning
- 面试官: 线程池是如何做到线程复用的?有了解过吗,说说看
- Visual Studio 2019软件安装包和安装教程
- What you have to know under the digital collection boom
- 10 years of testing experience, worthless in the face of the physiological age of 35
猜你喜欢

逆向调试入门-PE结构详解02/07

【TcaplusDB知识库】TcaplusDB技术支持介绍

平台即代码的未来是Kubernetes扩展

【初学者必看】vlc实现的rtsp服务器及转储H264文件

The world has embraced Web3.0 one after another, and many countries have clearly begun to seize the initiative

General solution of island problems and DFS framework

运维-- 统一网关非常必要

The sadness of software testers is Their own technical ability can not meet the requirements of large manufacturers?
![[recommendation system] esmm model of multi task learning (updating)](/img/21/8e38d3903eb1110efc4773edb2d09c.png)
[recommendation system] esmm model of multi task learning (updating)

Today's sleep quality record is 80 points
随机推荐
Slim GAIN(SGAIN)介绍及代码实现——基于生成对抗网络的缺失数据填补
RedmiBook Pro 14增强版 打不开台达软件DRAStudio_v1.00.07.52
机器学习之卷积神经网络Lenet5训练模型
【Hot100】2. Add two numbers
js中订阅发布模式bus
The first place on the list - brake by wire "new cycle", the market competitiveness of local suppliers is TOP10
Steps to be taken for successful migration to the cloud
面试官: 线程池是如何做到线程复用的?有了解过吗,说说看
昨日元宇宙|Meta “元宇宙”部门一季度亏损29.6亿美元,六福珠宝发行数字藏品
岛屿类问题通用解法与DFS框架
[recommendation system] esmm model of multi task learning (updating)
物联网云融合安全指南
【Golang】安装 iris 的方法
Zuckerberg to investors: don't expect anything from metauniverse
【Hot100】3. 无重复字符的最长子串
Knowing these commands allows you to master shell's own tools
零钱兑换(动态规划)
A new 25K byte from the Department showed me what the ceiling is
逆向调试入门-PE结构详解02/07
What are the most powerful small and medium-sized companies in Beijing?