Skip to content

Commit 35fc0f6

Browse files
package-lock.json
2 parents 42d3633 + 2981c1f commit 35fc0f6

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

examples/example.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ const client = new services.GatewayAPIClient(
1616
grpc.credentials.createInsecure()
1717
);
1818

19-
let metadata = new grpc.Metadata();
20-
2119
async function authenticate() {
2220
const req = new messages.AuthenticateRequest();
2321
req.setType('basic');
@@ -37,7 +35,6 @@ async function authenticate() {
3735

3836
// add the token to the metadata for subsequent client calls
3937
const token = res.getToken();
40-
metadata.add(TOKEN_HEADER, token);
4138
// one exception is the 'WhoAmI' method, which takes the token as a request parameter
4239
return token;
4340
}
@@ -55,10 +52,10 @@ async function whoAmI(token) {
5552
console.log('DisplayName from WhoAmIResponse:', user? user.getDisplayName() : '?');
5653
}
5754

58-
async function listReceivedOCMShares(token) {
55+
async function listReceivedOCMShares(metadata) {
5956
const req = new ListReceivedOCMSharesRequest();
6057
// req.setToken(token);
61-
const shares = await new Promise((resolve, reject) => client.listReceivedOCMShares(req, (err, res) => {
58+
const shares = await new Promise((resolve, reject) => client.listReceivedOCMShares(req, metadata, (err, res) => {
6259
if (err) {
6360
reject(err);
6461
}
@@ -70,7 +67,11 @@ async function listReceivedOCMShares(token) {
7067
async function example() {
7168
const token = await authenticate();
7269
await whoAmI(token);
73-
await listReceivedOCMShares(token);
70+
71+
const metadata = new grpc.Metadata();
72+
metadata.add(TOKEN_HEADER, token);
73+
74+
await listReceivedOCMShares(metadata);
7475
}
7576

7677
// ...

examples/example.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ const client = new GatewayAPIClient(
2121
credentials.createInsecure()
2222
);
2323

24-
let metadata = new Metadata();
25-
2624
async function authenticate() {
2725
const req = new AuthenticateRequest();
2826
req.setType('basic');
@@ -44,7 +42,6 @@ async function authenticate() {
4442

4543
// add the token to the metadata for subsequent client calls
4644
const token = res.getToken();
47-
metadata.add(TOKEN_HEADER, token);
4845
// one exception is the 'WhoAmI' method, which takes the token as a request parameter
4946
return token;
5047
}
@@ -64,11 +61,11 @@ async function whoAmI(token: string) {
6461
console.log('DisplayName from WhoAmIResponse:', user? user.getDisplayName() : '?');
6562
}
6663

67-
async function listReceivedOCMShares() {
64+
async function listReceivedOCMShares(metadata: Metadata) {
6865
const req = new ListReceivedOCMSharesRequest();
6966
// req.setToken(token);
7067
const shares: ListReceivedOCMSharesResponse = await new Promise((resolve, reject) => {
71-
client.listReceivedOCMShares(req, (err: ServiceError | null, res: ListReceivedOCMSharesResponse) => {
68+
client.listReceivedOCMShares(req, metadata, (err: ServiceError | null, res: ListReceivedOCMSharesResponse) => {
7269
if (err) {
7370
reject(err);
7471
}
@@ -81,7 +78,11 @@ async function listReceivedOCMShares() {
8178
async function example() {
8279
const token = await authenticate();
8380
await whoAmI(token);
84-
await listReceivedOCMShares();
81+
82+
const metadata = new Metadata();
83+
metadata.add(TOKEN_HEADER, token);
84+
85+
await listReceivedOCMShares(metadata);
8586
}
8687

8788
// ...

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cs3org/node-cs3apis",
3-
"version": "0.0.18",
3+
"version": "0.0.25",
44
"description": "Node.js bindings for the CS3APIs to connect Storage and Application Providers ",
55
"scripts": {
66
"test": "echo \"Error: no test specified\" && exit 1"

0 commit comments

Comments
 (0)