Hi, I am trying to use the java client (0.4.0) to ...
# spicedb
m
Hi, I am trying to use the java client (0.4.0) to connect to a local instance of spicedb in docker. I am getting "unauthenticated" back from the server. Is the bearer token supposed to be the grpc preshared key set as an env var? Or am i missing something else (attached error and code)
Copy code
io.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)
Copy code
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 🙂