简体   繁体   中英

Google Cloud 403 Error The billing account for the owning project is disabled in state absent

I went on Google Cloud and enabled a project, billing, and the Cloud Speech to Text API. Then I downloaded a.json file. Then I tried to execute this basic code in PyCharm.

    import os
    os.environ['GOOGLE_APPLICATION_CREDENTIALS'] ="instant-medium-282.json"
    
    from google.cloud import speech_v1
    from google.cloud.speech_v1 import enums
    
    client = speech_v1.SpeechClient()
    
    encoding = enums.RecognitionConfig.AudioEncoding.FLAC
    sample_rate_hertz = 44100
    language_code = 'en-US'
    config = {'encoding': encoding, 'sample_rate_hertz': sample_rate_hertz, 'language_code': language_code}
    uri = 'gs://bucket_name/file_name.flac'
    audio = {'uri': uri}
    
    response = client.recognize(config, audio)

However, I keep getting this error:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 57, in error_remapped_callable
    return callable_(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/grpc/_channel.py", line 826, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/grpc/_channel.py", line 729, in _end_unary_response_blocking
    raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.PERMISSION_DENIED
    details = "The billing account for the owning project is disabled in state absent"
    debug_error_string = "{"created":"@1593884707.640503000","description":"Error received from peer ipv6:[2607:f8b0:4009:813::200a]:443","file":"src/core/lib/surface/call.cc","file_line":1055,"grpc_message":"The billing account for the owning project is disabled in state absent","grpc_status":7}"
>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/sal.py", line 16, in <module>
    response = client.recognize(config, audio)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/cloud/speech_v1/gapic/speech_client.py", line 255, in recognize
    return self._inner_api_calls["recognize"](
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/api_core/gapic_v1/method.py", line 143, in __call__
    return wrapped_func(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/api_core/retry.py", line 281, in retry_wrapped_func
    return retry_target(
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/api_core/retry.py", line 184, in retry_target
    return target()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/api_core/timeout.py", line 214, in func_with_timeout
    return func(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 59, in error_remapped_callable
    six.raise_from(exceptions.from_grpc_error(exc), exc)
  File "<string>", line 3, in raise_from
google.api_core.exceptions.PermissionDenied: 403 The billing account for the owning project is disabled in state absent

I also confirmed with Google Cloud customer support that billing is enabled as it should be. Any suggestions on how to fix this error?

I ran into an issue while uploading a file using the CLI where I was trying to copy into a bucket that did not actually exist. It threw this same error "AccessDeniedException: 403 The billing account for the owning project is disabled in state closed".

If all was well with billing, perhaps the bucket you were pointing to did not exist?

Just wanted to flag that there seem to be non-billing reasons for such an error could be thrown..

The "The billing account for the owning project is disabled in state absent" error message,may happen when the API has just been enabled recently. So it is recommended to try again.

In my case,

"AccessDeniedException: 403 The billing account for the owning project is disabled in state closed"

happen, because I didn't added 'Billing Account' to the project I've created. You can link your project to a Billing Account in Billing Projects tab. Once you did so, wait some time and the error should gone.

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