【发布时间】:2020-06-29 19:18:03
【问题描述】:
我是基本身份验证和令牌的新手。
我一直在玩邮递员,以便使用基本身份验证获取令牌,然后将令牌作为不记名令牌传递以访问另一个端点。我想知道如何使用 node 和 express 将其编码为 api 调用。
我知道对于基本身份验证,我需要将客户端 ID 和密码编码为 base64
curl --request POST \
--url http://localhost:8080/token/ \
--header 'authorization: Basic ***' \
--header 'content-type: application/x-www-form-urlencoded' \
--data
grant_type=credentials
我从上面的调用中得到的令牌我想传递给下面的调用
curl --request POST \
--url http://localhost:8080/login \
--header 'authorization: Bearer ***' \
--header 'content-type: application/x-www-form-urlencoded' \
--data
user=1
这在节点应用程序中如何作为代码
【问题讨论】:
标签: node.js express authentication token