Boxで外部のユーザーを取るやり方(box-node-sdkの場合)
box-node-sdkをつかって、外部ユーザーを取得するやりかたがわからなかったので調べました。
他のSDKでも考え方は同じはず。
以下やり方。
const boxSDK = require("box-node-sdk");
const config = require("./config"); // config.json
const main = async () => {
const sdk = boxSDK.getPreconfiguredInstance(config);
const saClient = await sdk.getAppAuthClient("enterprise");
const anExternalUser = await saClient.enterprise.getUsers({
filter_term: "taro.yamada@example.com",
user_type: "external",
});
console.log(anExternalUser);
};
main();
ポイントは、filter_term
にname
もしくはlogin
を完全な形で入れることと、user_type
にexternal
を指定することみたいです。
外部ユーザーの取得は、1レコードずつしか取れないようですね。
1レコードずつしか取れないのはいいとして、そもそも、名前とかLoginをどうやって取得するんだって話もあります・・・。
コラボレーションとかから引っ張ってくる感じなのかなと想像しますが、今度調べときます。