title: PermissionDenied: 403 error when I'm using Google Cloud Billing Budget API
body: <p>I'm using Google cloud functions and the <code>Cloud Billing Budget API</code> to get a list with all of my budgets, but I'm having the following error:</p>
  <p><code>Traceback (most recent call last): File &quot;/env/local/lib/python3.7/site-packages/google/api_core/grpc_helpers.py&quot;, line 67, in error_remapped_callable return callable_(*args, **kwargs) File &quot;/env/local/lib/python3.7/site-packages/grpc/_channel.py&quot;, line 946, in __call__ return _end_unary_response_blocking(state, call, False, None) File &quot;/env/local/lib/python3.7/site-packages/grpc/_channel.py&quot;, line 849, in _end_unary_response_blocking raise _InactiveRpcError(state) grpc._channel._InactiveRpcError: &lt;_InactiveRpcError of RPC that terminated with: status = StatusCode.PERMISSION_DENIED details = &quot;The caller does not have permission&quot;</code></p>
  <p><code>debug_error_string = &quot;{&quot;created&quot;:&quot;@9627456.9324530376&quot;,&quot;description&quot;:&quot;Error received from peer ipv4:54.128.19.5:443&quot;,&quot;file&quot;:&quot;src/core/lib/surface/call.cc&quot;,&quot;file_line&quot;:1069,&quot;grpc_message&quot;:&quot;The caller does not have permission&quot;,&quot;grpc_status&quot;:7}&quot; &gt; The above exception was the direct cause of the following exception: Traceback (most recent call last): File &quot;/env/local/lib/python3.7/site-packages/google/cloud/functions/worker_v2.py&quot;, line 449, in run_background_function _function_handler.invoke_user_function(event_object) File &quot;/env/local/lib/python3.7/site-packages/google/cloud/functions/worker_v2.py&quot;, line 268, in invoke_user_function return call_user_function(request_or_event) File &quot;/env/local/lib/python3.7/site-packages/google/cloud/functions/worker_v2.py&quot;, line 265, in call_user_function event_context.Context(**request_or_event.context)) File &quot;/user_code/main.py&quot;, line 22, in getting_data all_budgets = client.list_budgets(request = {'parent': BILLING_ACCOUNT}) File &quot;/env/local/lib/python3.7/site-packages/google/cloud/billing/budgets_v1/services/budget_service/client.py&quot;, line 693, in list_budgets response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) File &quot;/env/local/lib/python3.7/site-packages/google/api_core/gapic_v1/method.py&quot;, line 145, in __call__ return wrapped_func(*args, **kwargs) File &quot;/env/local/lib/python3.7/site-packages/google/api_core/retry.py&quot;, line 290, in retry_wrapped_func on_error=on_error, File &quot;/env/local/lib/python3.7/site-packages/google/api_core/retry.py&quot;, line 188, in retry_target return target() File &quot;/env/local/lib/python3.7/site-packages/google/api_core/grpc_helpers.py&quot;, line 69, in error_remapped_callable six.raise_from(exceptions.from_grpc_error(exc), exc) File &quot;&lt;string&gt;&quot;, line 3, in raise_from google.api_core.exceptions.PermissionDenied: 403 The caller does not have permission</code></p>
  <p>What I've done is give the appropriate permissions (<code>billing.budget.list</code> ... <code>billing.budget.get</code> ... etc ) at the organization level to the service account of the function, but it does not work.</p>
  <p>My code is this:</p>
  <pre><code>#main.py
  
  import os
  import get_budgets
  from google.cloud.billing import budgets
  
  def getting_data(data, context):
      BILLING_ACCOUNT = 'billingAccounts/XXXXXX-XXXXXX-XXXXXX'
      client = budgets.BudgetServiceClient()
      
      all_budgets = client.list_budgets(request = {'parent': BILLING_ACCOUNT})
      budget_actions.budget_list(all_budgets)
  </code></pre>
  <pre><code>#get_budgets.py
  
  from google.cloud.billing import budgets
  from googleapiclient import discovery
  
  #BUDGET LIST
  def budget_list(all_budgets):
      print('Budget summary')
      
      for budget in all_budgets:
          print(f'Name: {budget.display_name}')
  
          b_amount = budget.amount
          if 'specified_amount' in b_amount:
              print(f'Specified Amount: {b_amount.specified_amount.units} {b_amount.specified_amount.currency_code}')
  
          if 'last_period_amount' in b_amount:
              print('Dynamic spend (based on last period)')
  
          print('')
  </code></pre>
  <p>Is there something that I've forgotten?</p>