简体   繁体   中英

Google cloud dataflow restapi always returns 403-SERVICE_DISABLED

I have this dependency

<dependency>
    <groupId>com.google.apis</groupId>
    <artifactId>google-api-services-dataflow</artifactId>
    <version>v1b3-rev20221025-2.0.0</version>
</dependency>

Here i am building the dataflow:

private fun dataflow(): Dataflow = Dataflow.Builder(
    "My credentials",
    ...,
    ...
).build()

When i try to invoke some of the dataflow methods it always returns 403-SERVICE_DISABLED although i have pipelines with jobs in my project.

EX:

dataflow().projects().jobs().list("myProjectId").execute()

I tried changing the dependency version, calling different methods but the result is the same. I have dependencies for other resources and they works fine.

You appear to be using the Google apis java client library when you should be using the google cloud java client libary .

You should consult the documentation here google-cloud-dataflow overview (0.10.0)

 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (JobsV1Beta3Client jobsV1Beta3Client = JobsV1Beta3Client.create()) {
   CreateJobRequest request =
       CreateJobRequest.newBuilder()
           .setProjectId("projectId-894832108")
           .setJob(Job.newBuilder().build())
           .setView(JobView.forNumber(0))
           .setReplaceJobId("replaceJobId441554788")
           .setLocation("location1901043637")
           .build();
   Job response = jobsV1Beta3Client.createJob(request);
 }
 

I found the solution. The problem was that the service account which i provide as ServiceAccountCredential was in another project where this API was not enabled. So the API have to be enabled in the project where service account is located and in the project, where my resources are located.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM