title: Google Cloud Platform Authentification: Recognized as end user anthentification despite using a service account
body: <p>Anyone can HELP? This one is really driving me crazy... Thank you!</p>
  
  <p>I tried to use a google cloud platform API Speech-to-text.</p>
  
  <p>Tools: WINDOWS 10 &amp;&amp; GCP &amp;&amp;Python(Pycharm IDE)</p>
  
  <ol>
  <li><p>I've created a service account as a owner for my speech-to-test project and generated a key from GCP console in json, then I set the environment variables.
  Code I ran on WIN10 Powershell &amp;&amp; CMD:</p>
  
  <pre><code>$env:GOOGLE_APPLICATION_CREDENTIALS="D:\GCloud speech-to-text\Speech 
  To Text Series-93e03f36bc9d.json"
  
  set GOOGLE_APPLICATION_CREDENTIALS=D:\GCloud speech-to-text\Speech To 
  Text Series-93e03f36bc9d.json
  </code></pre>
  
  <p>PS: the added environment variables disappear in CMD and Powershell after reboot my laptop but do show in the env list if added again.</p></li>
  <li><p>I've enabled the google storage api and google speech-to-text api in GCP console.</p></li>
  <li><p>I've tried the explicitely showing credential method via python, same problem.</p></li>
  <li><p>I've installed the google cloud SDK shell and initialized by using command to log in my account.</p></li>
  </ol>
  
  <p>PYTHON SPEECH-TO-TEXT CODE(from GCP demo)</p>
  
  <pre><code>import io
  import os
  
  # Imports the Google Cloud client library
  from google.cloud import speech
  from google.cloud.speech import enums
  from google.cloud.speech import types
  
  # Instantiates a client
  client = speech.SpeechClient()
  
  # The name of the audio file to transcribe
  file_name = os.path.join(
      os.path.dirname(__file__),
      'test_cre.m4a')
  
  # Loads the audio into memory
  with io.open(file_name, 'rb') as audio_file:
      content = audio_file.read()
      audio = types.RecognitionAudio(content=content)
  
  config = types.RecognitionConfig(
      encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,
      sample_rate_hertz=16000,
      language_code='en-US')
  
  # Detects speech in the audio file
  response = client.recognize(config, audio)
  
  for result in response.results:
      print('Transcript: {}'.format(result.alternatives[0].transcript))
  </code></pre>
  
  <p>----Expected to receive a "200OK" and the transcribed text when runing the code above (a demo of short speech to text api from GCP Document)</p>
  
  <p>----But got:</p>
  
  <ol>
  <li><p>D:\Python\main program\lib\site-packages\google\auth_default.py:66: UserWarning: Your application has authenticated using end user credentials from Google Cloud SDK. We recommend that most server applications use service accounts instead. If your application continues to use end user credentials from Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error. For more information about service accounts, see <a href="https://cloud.google.com/docs/authentication/" rel="nofollow noreferrer">https://cloud.google.com/docs/authentication/</a>
  warnings.warn(_CLOUD_SDK_CREDENTIALS_WARNING)</p></li>
  <li><p>google.api_core.exceptions.ResourceExhausted: 429 Quota exceeded for quota metric 'speech.googleapis.com/default_requests' and limit 'DefaultRequestsPerMinutePerProject' of service 'speech.googleapis.com' for consumer 'project_number:764086051850'.</p>
  
  <p><strong><em>ANOTHER WEIRD THING</em></strong>: the error info shows that 'project_number:764086051850', which is different from my speech-to-text project_number on GCP (I do distinguish project number and project ID), the project_number shown in the error info also varies every time the code runs. It seems I was sending cloud requirement of the wrong project?</p></li>
  <li><p>My GOOGLE_APPLICATION_CREDENTIALS system environment variables disappear after I restart my laptop next time. After adding again, it will appear in the env list but can't be stored after reboot again.</p></li>
  </ol>
  
  <p>Appreciate it if someone can help, thank you!</p>