question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

language: DefaultCredentialsError: Could not automatically determine credentials

See original GitHub issue

I use Google cloud’s Natural Language API from this link: And I use this command in powershell :

 $env:GOOGLE_APPLICATION_CREDENTIALS="D:\analyze_sentiment\MyFirstProject-bbe4f7bccb98.json"

Then I use this command in cmd:

set GOOGLE_APPLICATION_CREDENTIALS=D:\analyze_sentiment\MyFirstProject-bbe4f7bccb98.json

But when I use python code:

from google.cloud import language
from google.cloud.language import enums
from google.cloud.language import types

# Instantiates a client
client = language.LanguageServiceClient()
# The text to analyze
text = u'Hello, world!'
document = types.Document(
    content=text,
    type=enums.Document.Type.PLAIN_TEXT)
# Detects the sentiment of the text
sentiment = client.analyze_sentiment(document=document).document_sentiment
print('Text: {}'.format(text))
print('Sentiment: {}, {}'.format(sentiment.score, sentiment.magnitude))

The error message said:

raise exceptions.DefaultCredentialsError(_HELP_MESSAGE) google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://developers.google.com/accounts/docs/application-default-credentials.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:26 (7 by maintainers)

github_iconTop GitHub Comments

16reactions
vroon5commented, Jun 11, 2018

The following solution worked. : explicitly mentioning the location of the private key https://google-auth.readthedocs.io/en/latest/user-guide.html#service-account-private-key-files image

9reactions
sylwester-prymulacommented, Nov 14, 2019

image I cannot completely interpret the output of set, but I assume this is your question. It identifies that google application credentials above path.

set path without quotation marks! set GOOGLE_APPLICATION_CREDENTIALS=[PATH]

wrong: set GOOGLE_APPLICATION_CREDENTIALS=“[PATH]”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: google.auth.exceptions.DefaultCredentialsError: Could ...
DefaultCredentialsError: Could not automatically determine credentials. ... See the License for the specific language governing permissions and
Read more >
Set GOOGLE_APPLICATION_CREDENTIALS in Python ...
DefaultCredentialsError : Could not > automatically determine credentials. Please set > GOOGLE_APPLICATION_CREDENTIALS or explicitly create ...
Read more >
google-auth 1.30.0 documentation - Read the Docs
External account credentials project IDs may not always be determined. Raises: google.auth.exceptions.DefaultCredentialsError: if the file is in the wrong ...
Read more >
Authenticate to Cloud services using client libraries
This page describes how you can use client libraries and Application Default Credentials to access Google APIs. Client libraries make it easier to...
Read more >
please set google_application_credentials - You.com | The AI ...
DefaultCredentialsError : Could not automatically determine credentials ... Thank you. My programming language is .net using visual studio 2012 + IIS 6.0.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found