google cloud platform – Big query Storage API permission issue

I am using a service account to write data to Big query using big query storage API using java SDK, and I see the below error. Do I need to provide any other roles to the service account?

Error: 00:44:38 | Error: io.grpc.StatusRuntimeException: PERMISSION_DENIED: Request had insufficient authentication scopes.

Current Roles to the service account: BigQuery Admin, BigQuery Data Owner, BigQuery Data Editor

code snippet:

        Map<String, Object> metadata = new HashMap<>();
        metadata.put("table_name", "MetaData");
        metadata.put("is_processed", false);
        JSONObject jsonObject = new JSONObject(metadata);
        TableName parentTable = TableName.of("test", "test", "MetaData");

        WriteStream stream = WriteStream.newBuilder().setType(WriteStream.Type.COMMITTED).build();

        CreateWriteStreamRequest createWriteStreamRequest =
        WriteStream writeStream = bigQueryWriteClient.createWriteStream(createWriteStreamRequest);

        // Use the JSON stream writer to send records in JSON format.
        // For more information about JsonStreamWriter, see:
        JsonStreamWriter streamWriter = JsonStreamWriter.newBuilder(writeStream.getName(), writeStream.getTableSchema()).build();
        JSONArray arr = new JSONArray();
        // Append asynchronously for increased throughput.
        ApiFuture<AppendRowsResponse> future = streamWriter.append(arr, 1);
                future, new AppendCompleteCallback(), MoreExecutors.directExecutor());

Read more here: Source link