gifted-gold-29282
02/02/2023, 1:54 AMimport * as grpc from '@grpc/grpc-js';
import keto from '@ory/keto-grpc-client';
// Making user_id to have viewer relation to org_id organization.
const writeClient = new keto.writeService.WriteServiceClient(
'127.0.0.1:4467',
grpc.credentials.createInsecure()
);
const relationTuple = new keto.relationTuples.RelationTuple();
relationTuple.setNamespace('Organization');
relationTuple.setObject('org_id');
relationTuple.setRelation('viewer');
const subject = new keto.relationTuples.Subject();
subject.setId('user_id');
relationTuple.setSubject(subject);
const tupleDelta = new keto.write.RelationTupleDelta();
tupleDelta.setAction(keto.write.RelationTupleDelta.Action.ACTION_INSERT);
tupleDelta.setRelationTuple(relationTuple);
const writeRequest = new keto.write.TransactRelationTuplesRequest();
writeRequest.addRelationTupleDeltas(tupleDelta);
writeClient.transactRelationTuples(writeRequest, (error) => {
if (error) {
console.log('Encountered error', error);
} else {
console.log('Successfully created tuple');
}
});
I am wondering if there are any examples on how this should work? Do we need to pre-register Orgs and Users with Tuples and cli command?
Cannot understand why it keep saying that it cannot find Organization namespace. Any suggestions or advice?steep-lamp-91158
steep-lamp-91158
steep-lamp-91158