Giter Site home page Giter Site logo

js-cs3apis's Introduction

js-cs3apis's People

Contributors

2403905 avatar aduffeck avatar butonic avatar c0rby avatar cs3org-bot avatar dragonchaser avatar glpatcern avatar gmgigi96 avatar ishank011 avatar javfg avatar kobergj avatar labkode avatar lovisalugnegard avatar micbar avatar redblom avatar refs avatar samualfageme avatar wkloucek avatar

Watchers

 avatar  avatar

js-cs3apis's Issues

core access token not found

This might be a user problem, but I'm investigating the following error:

const util = require('util');
const grpc = require('grpc');
const { GatewayAPIClient } = require('@cs3org/node-cs3apis/cs3/gateway/v1beta1/gateway_api_grpc_pb');
const { AuthenticateRequest, WhoAmIRequest } = require('@cs3org/node-cs3apis/cs3/gateway/v1beta1/gateway_api_pb');
const { ListReceivedOCMSharesRequest } = require('@cs3org/node-cs3apis/cs3/sharing/ocm/v1beta1/ocm_api_pb');

const TARGET = process.env.TARGET || 'localhost:19000';

function promisifyMethods(instance, methodNames) {
  const result = {};
  methodNames.forEach(methodName => {
    result[methodName] = util.promisify(instance[methodName].bind(instance));
  });
  return result;
}

const client = promisifyMethods(new GatewayAPIClient(TARGET, grpc.credentials.createInsecure()), [
  'authenticate',
  'listReceivedOCMShares',
  'whoAmI'
]);

async function example() {
  try {
    const req1 = new AuthenticateRequest();
    req1.setType('basic');
    req1.setClientId('einstein');
    req1.setClientSecret('relativity');
    const res1 = await client.authenticate(req1);
    // See:
    // * AuthenticateResponse https://github.com/cs3org/cs3apis/blob/a86e5cb6ac360/cs3/gateway/v1beta1/gateway_api.proto#L415
    // * User https://github.com/cs3org/cs3apis/blob/a86e5cb6ac360/cs3/identity/user/v1beta1/resources.proto#L53
    console.log(res1.getUser().getDisplayName());
    const req2 = new WhoAmIRequest();
    // req2.setIncludeInstance(true);
    const res2 = await client.whoAmI(req2);
    console.log(res2);
    const shares = await client.listReceivedOCMShares(new ListReceivedOCMSharesRequest());
    console.log(shares);
  } catch (e) {
    console.error(e);
  }
}

// ...
example();

Outputs:

Albert Einstein
{
  wrappers_: {
    '1': {
      wrappers_: null,
      messageId_: undefined,
      arrayIndexOffset_: -1,
      array: [Array],
      pivot_: 1.7976931348623157e+308,
      convertedPrimitiveFields_: {}
    }
  },
  messageId_: undefined,
  arrayIndexOffset_: -1,
  array: [
    [
      9,
      'error dismantling token',
      'b1df4dfd84d77f1586d68ad56a11995a'
    ]
  ],
  pivot_: 1.7976931348623157e+308,
  convertedPrimitiveFields_: {}
}
Error: 2 UNKNOWN: gateway: error calling ListReceivedShares: rpc error: code = Unauthenticated desc = auth: core access token not found
    at Object.exports.createStatusError (/Users/michiel/gh/cs3org/ocm-test-suite/node_modules/grpc/src/common.js:91:15)
    at Object.onReceiveStatus (/Users/michiel/gh/cs3org/ocm-test-suite/node_modules/grpc/src/client_interceptors.js:1209:28)
    at InterceptingListener._callNext (/Users/michiel/gh/cs3org/ocm-test-suite/node_modules/grpc/src/client_interceptors.js:568:42)
    at InterceptingListener.onReceiveStatus (/Users/michiel/gh/cs3org/ocm-test-suite/node_modules/grpc/src/client_interceptors.js:618:8)
    at callback (/Users/michiel/gh/cs3org/ocm-test-suite/node_modules/grpc/src/client_interceptors.js:847:24) {
  code: 2,
  metadata: Metadata { _internal_repr: {}, flags: 0 },
  details: 'gateway: error calling ListReceivedShares: rpc error: code = Unauthenticated desc = auth: core access token not found'
}

TypeError: Cannot read property 'MethodInfo' of undefined

When using the latest release (0.0.35) I get the error TypeError: Cannot read property 'MethodInfo' of undefined when trying to import the GatewayAPIClient.

import {
    GatewayAPIClient,
} from "@cs3org/cs3apis/cs3/gateway/v1beta1/gateway_api_grpc_web_pb.js";

However, if I edit the file gateway_api_grpc_web_pb.js and add the following code at line 13 (just after grpc.web = require('grpc-web')) the import statement works.

grpc.web.AbstractClientBase = {
         MethodInfo: function() {}
}

Version of grpc-web is 1.3.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.