node.js - 在 ADP API 中获取 accessToken
问题描述
我正在尝试使用 NodeJS 在 ADP API 中获取 access_token。建立连接后,我可以清楚地看到我的 accessToken,但我无法访问它并使用它向其他 ADP 端点发出正确的获取请求。我试图将访问令牌设置到我的 connectionOpts 对象中。任何帮助表示赞赏
const connectionOpts = {
clientId: 'xxxxxx',
clientSecret: 'xxxxx',
granttype: 'client_credentials',
sslCertPath: './certs/xxxx_auth.pem',
sslKeyPath: './certs/xxxx_auth.key'
}
//Create connection object for application
const connection = new adpConnection.createConnection(connectionOpts)
const connectionComplete = (error) => {
if (error) {
console.log('Not Connected', error)
} else {
console.log('Connected with Token ' + connection.accessToken) //Connected with Token 4cb1a418-f2fb-4ac2-972f-8c00b59dcff0
connectionOpts.authCode = connection.accessToken
console.log("ConnectionOpts", connectionOpts)
}
}
connection.connect(connectionComplete)
解决方案
推荐阅读
- python - 包含黑色代码格式化程序行长忽略注释
- javascript - 将 div 放在第三个 td 下并根据第三个 td 高度更改它的 Y 位置
- c++ - 自动解包一对迭代器
- postgresql - 将变量从一个 sql 脚本传递到另一个作为 postgres sql 中的参数
- firebase - 如何在 Flutter 中查询其字段值包含在本地列表变量中的 Firestore 数据
- c# - 使用 linq 排序、区分并选择前 5 个结果
- powershell - Test-WSMan 上的 if/else 语句
- javascript - 从有效负载中删除密钥
- google-sheets - 与多个工作表相比,识别列表中的新项目
- ansible - import_role 和 include_role 在变量优先级方面的区别