Comments (9)
不需要拿token哈,直接语义化调用api就好
from node-sdk.
不需要拿token哈,直接语义化调用api就好
我如果要导出一个电子表格, 那么参数里面就需要填写tenantAccessToken.
client.drive.exportTask.get({
path: {
ticket: '7281281080657264644',
},
params: {
token: 'PbgysKgBKho6iJt6fytcpsaSncg',
},
},
lark.withTenantToken("t-g1049lm9NM75KRX3OVSJA4C5IKZWPLDU76LOPGEK")
).then(res => {
console.log(res);
});
这个tenantAccessToken不能写死,会过期。我不拿token,如果导出电子表格呢?
from node-sdk.
token内部会自动获取,不需要手动拿。new完client后,直接这样调用:
client.drive.exportTask.get({
path: {
ticket: '7281281080657264644',
},
params: {
token: 'PbgysKgBKho6iJt6fytcpsaSncg',
},
},
from node-sdk.
token内部会自动获取,不需要手动拿。new完client后,直接这样调用: client.drive.exportTask.get({ path: { ticket: '7281281080657264644', }, params: { token: 'PbgysKgBKho6iJt6fytcpsaSncg', }, },
这个项目和飞书开放平台服务器api文档是关联的吗?对于使用者,刚开始接触我目前只知道可以通过这个平台文档来学习使用。平台文档的示例代码这么写会给开发者很困惑
from node-sdk.
了解~感谢同学反馈。因为调试台页面中已经拿了一遍token,因此示例代码中使用已经存在的这个token,方便copy代码后可以跑通。示例中对这点加了注释,产生困惑的原因可能是这块没有表达清楚,我们想想怎么优化一下。
可以阅读一下sdk的readme哈,比较清楚:https://github.com/larksuite/node-sdk/blob/main/README.zh.md
from node-sdk.
。。。。,我也是醉了,飞书平台api文档大家感受一下灵魂就好,不要copy,全是坑。把disableTokenCache: true在new lark.Client里面注释掉就可以了。
const client = new lark.Client({
appId: 'cli_xxxxxxxx',
appSecret: 'xxxxxxxx',
// disableTokenCache为true时,SDK不会主动拉取并缓存token,这时需要在发起请求时,调用lark.withTenantToken("token")手动传递
// disableTokenCache为false时,SDK会自动管理租户token的获取与刷新,无需使用lark.withTenantToken("token")手动传递token
//disableTokenCache: true
});
client.drive.exportTask.create({
data: {
file_extension: 'xlsx',
token: 'xxxxxxxx',
type: 'sheet',
},
},
lark.withTenantToken("")
).then(res => {
console.log(res);
});
from node-sdk.
了解~感谢同学反馈。因为调试台页面中已经拿了一遍token,因此示例代码中使用已经存在的这个token,方便copy代码后可以跑通。示例中对这点加了注释,产生困惑的原因可能是这块没有表达清楚,我们想想怎么优化一下。
可以阅读一下sdk的readme哈,比较清楚:https://github.com/larksuite/node-sdk/blob/main/README.zh.md
现在我的诉求是下载一个线上的电子表格,
client.drive.exportTask.create({
data: {
file_extension: 'xlsx',
token: 'xxxxxxxxxxxx',
type: 'sheet',
},
}
).then(res => {
console.log(res);
client.drive.exportTask.get({
path: {
ticket: res.data.ticket
},
params: {
token: 'PbgysKgBKho6iJt6fytcpsaSncg',
},
}
).then(res => {
console.log(res);
});
});
我拿到的ticket:7281506777802358788。 我在飞书平台调试台拿到的ticket:7281506655445991428。结果不一样,然后我在通过拿到的ticket去调用 client.drive.exportTask.get, 结果是
{ code: 0, data: { ticket: '7281506777802358788' }, msg: 'success' }
{
code: 0,
data: {
result: {
file_extension: '',
file_name: '',
file_size: 0,
file_token: '',
job_error_msg: '',
job_status: 2,
type: ''
}
},
msg: 'success'
}
from node-sdk.
了解~感谢同学反馈。因为调试台页面中已经拿了一遍token,因此示例代码中使用已经存在的这个token,方便copy代码后可以跑通。示例中对这点加了注释,产生困惑的原因可能是这块没有表达清楚,我们想想怎么优化一下。
可以阅读一下sdk的readme哈,比较清楚:https://github.com/larksuite/node-sdk/blob/main/README.zh.md
如果我在new client的时候,将disableTokenCache:true打开,就会提示一下错误:
[error]: [
[
{
message: 'Request failed with status code 400',
config: [Object],
request: [Object],
response: [Object]
},
{
code: 99991661,
msg: 'Missing access token for authorization. Please make a request with token attached.',
error: [Object]
}
]
]
from node-sdk.
现在我的诉求是下载一个线上的电子表格,
client.drive.exportTask.create({ data: { file_extension: 'xlsx', token: 'xxxxxxxxxxxx', type: 'sheet', }, } ).then(res => { console.log(res); client.drive.exportTask.get({ path: { ticket: res.data.ticket }, params: { token: 'PbgysKgBKho6iJt6fytcpsaSncg', }, } ).then(res => { console.log(res); }); });
我拿到的ticket:7281506777802358788。 我在飞书平台调试台拿到的ticket:7281506655445991428。结果不一样,然后我在通过拿到的ticket去调用 client.drive.exportTask.get, 结果是 { code: 0, data: { ticket: '7281506777802358788' }, msg: 'success' } { code: 0, data: { result: { file_extension: '', file_name: '', file_size: 0, file_token: '', job_error_msg: '', job_status: 2, type: '' } }, msg: 'success' }
这个用法是对的,ticket应该是每次调用接口都会生成一个新的
from node-sdk.
Related Issues (20)
- sdk没有像http请求一样返回错误信息(code和msg)
- 使用自定义axios实例时,TokenManager中获取TenantAccessToken时使用了错误的返回值 HOT 1
- 通讯录中批量获取用户这个方法在SDK中不存在 HOT 2
- approval 事件订阅缺失 HOT 3
- Can not upload files HOT 5
- 想问下code-gen是如何自动生成的 HOT 1
- 这个验证请求的代码是不是有问题 HOT 3
- 审批实例状态变更 这个事件可以用EventDispatcher来进行处理吗 HOT 1
- EventDispatcher 收到消息后不分发 HOT 1
- 字节内部也能用吧? HOT 2
- 下载文件能否支持直接导出流? HOT 1
- 【BUG】发送消息失败 HOT 18
- 多维表格:获取字段类型错误 HOT 3
- bug: 多维表格下的查询记录接口问题 HOT 2
- BUG:多维表格添加记录无法记录字段内容 HOT 1
- 新卡片回传交互结构类型不支持 HOT 2
- 文档错误 HOT 1
- 延时更新消息卡片接口不支持 HOT 1
- yarn.lock 中包含字节内网registry地址 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-sdk.