mattw
12/24/2022, 1:57 AMio.grpc.StatusRuntimeException: UNAUTHENTICATED
at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:271)
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:252)
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:165)
at com.authzed.api.v1.SchemaServiceGrpc$SchemaServiceBlockingStub.writeSchema(SchemaServiceGrpc.java:255)
java
ManagedChannel channel = ManagedChannelBuilder
.forTarget("localhost:50051")
.usePlaintext()
.build();
BearerToken bearerToken = new BearerToken("foobar");
SchemaServiceGrpc.SchemaServiceBlockingStub schemaService = SchemaServiceGrpc.newBlockingStub(channel)
.withCallCredentials(bearerToken);
String schema = """
definition blog/user {}
definition blog/post {
relation reader: blog/user
relation writer: blog/user
permission read = reader + writer
permission write = writer
}
""";
WriteSchemaRequest request = WriteSchemaRequest.newBuilder()
.setSchema(schema)
.build();
WriteSchemaResponse response;
try {
response = schemaService.writeSchema(request);
} catch (Exception e) {
e.printStackTrace();
return;
}
System.out.println(response);
any help is much appreciated 🙂