@@ -21,8 +21,6 @@ const client = new GatewayAPIClient(
2121 credentials . createInsecure ( )
2222) ;
2323
24- let metadata = new Metadata ( ) ;
25-
2624async 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() {
8178async 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// ...
0 commit comments