Comments (15)
Why is it looking at the wrong project?
Make sure your GCLOUD_PROJECT
environment variable is set to your Google project ID.
Command prompt:
set GCLOUD_PROJECT=your-project-id
set GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account_file.json
Powershell:
$env:GCLOUD_PROJECT="your-project-id"
$env:GOOGLE_APPLICATION_CREDENTIALS="/path/to/service_account_file.json"
from nodejs-docs-samples.
Hi @sonanhson, I found the solution, use the following code to add the environment variable, it works. But I don't know yet why the other approaches don't work.
import os
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "path_to_your_.json_credential_file"
This will also be useful when you are switching between projects that need different credentials.
from nodejs-docs-samples.
Hi jmdobry,
I know this post quite old. But I have the same problem about setting environment variable as below:
I want to use Google cloud vision API on Python. I have created a service account for authentication.
Based on the instruction of jmdobry in this post, I set the environment variable with the following commands in cmd (Windows 7)
set GCLOUD_PROJECT=my-project-id
set GOOGLE_APPLICATION_CREDENTIALS=C:/Python install/Google API/filename.JSON
Then, I run the following Python code to test the first API request:
import io
import os
from google.cloud import vision
from google.cloud.vision import types
client = vision.ImageAnnotatorClient()
file_name = os.path.join(
os.path.dirname(file),
'C:/Python install/Python Test/Photos Testing/Lobstersize.jpg')
with io.open(file_name, 'rb') as image_file:
content = image_file.read()
image = types.Image(content=content)
response = client.label_detection(image=image)
labels = response.label_annotations
print('Labels:')
for label in labels:
print(label.description)
But, it shows an error as below:
Traceback (most recent call last):
File "GoogleAPI.py", line 9, in
client = vision.ImageAnnotatorClient()
File "C:\Python install\lib\site-packages\google\cloud\vision_v1\gapic\image_annotator_client.py", line 135, in __init
__
ssl_credentials=ssl_credentials)
File "C:\Python install\lib\site-packages\google\gax\grpc.py", line 106, in create_stub
credentials = _grpc_google_auth.get_default_credentials(scopes)
File "C:\Python install\lib\site-packages\google\gax_grpc_google_auth.py", line 62, in get_default_credentials
credentials, _ = google.auth.default(scopes=scopes)
File "C:\Python install\lib\site-packages\google\auth_default.py", line 292, in default
raise exceptions.DefaultCredentialsError(_HELP_MESSAGE)
google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICA
TION_CREDENTIALS or
explicitly create credential and re-run the application. For more
information, please see
https://developers.google.com/accounts/docs/application-default-credentials.
Please help me this issue.
Thank you very much.
Son.
from nodejs-docs-samples.
For Windows CMD:
set GCLOUD_PROJECT=foobar
set GOOGLE_APPLICATION_CREDENTIALS=path/to/your/file.json
Important!
I was really struggling with it since I noticed that the problem was due to double quotes
DON'T USE Double quotes!
from nodejs-docs-samples.
Hey Paul
I could get it working however not on windows 10 but it should not make any
difference
Have you run this line ?
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account_file.json
and created the right file for your application? if not go to
https://cloud.google.com/speech/docs/auth-template/cloud-api-auth#using_the_console_name_short
link which explains just fine how to do that. it works.
Counter question :
Do you have any idea when they will add wrapper for the streaming version too?
Cheers
Greg.
On 24 May 2016 at 16:47, paulcanning [email protected] wrote:
I cannot figure out how to set the GOOGLE_APPLICATION_CREDENTIALS on
Windows 10.The documentation is pretty sparse.
I have Node setup OK, and cloned this repo.
I get the following error when running the command node recognize
"resources/quit.raw"Got audio file!
Loading speech service...
{ [Error: Google Cloud Speech API has not been used in project google.com:cloudsdktool
before or it is disabled. Enable it by visiting
https://console.developers.google.com/apis/api/speech.googleapis.com/overview?project=google.com:cloudsdktool
then retry. If you enabled this API recently, wait a few minutes for the
action to propagate to our systems and retry.]
code: 403,
errors:
[ { message: 'Google Cloud Speech API has not been used in project
google.com:cloudsdktool before or it is disabled. Enable it by visiting
https://console.developers.google.com/apis/api/speech.googleapis.com/overview?project=google.com:cloudsdktool
then retry. If you enabled this API recently, wait a few minutes for the
action to propagate to our systems and retry.',
domain: 'global',
reason: 'forbidden' } ] }Why is it looking at the wrong project?
How do I set it to look at my project (I have a google project with speech
api enabled)—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#117
from nodejs-docs-samples.
export
is not a Windows command. (docs only cater for linux)
I got it working by manually adding the env variables in Windows (control panel, system, environment variables)
from nodejs-docs-samples.
Also check this out
http://stackoverflow.com/questions/9249830/how-can-i-set-node-env-production-in-windows
greg
On 24 May 2016 at 16:47, paulcanning [email protected] wrote:
I cannot figure out how to set the GOOGLE_APPLICATION_CREDENTIALS on
Windows 10.The documentation is pretty sparse.
I have Node setup OK, and cloned this repo.
I get the following error when running the command node recognize
"resources/quit.raw"Got audio file!
Loading speech service...
{ [Error: Google Cloud Speech API has not been used in project google.com:cloudsdktool
before or it is disabled. Enable it by visiting
https://console.developers.google.com/apis/api/speech.googleapis.com/overview?project=google.com:cloudsdktool
then retry. If you enabled this API recently, wait a few minutes for the
action to propagate to our systems and retry.]
code: 403,
errors:
[ { message: 'Google Cloud Speech API has not been used in project
google.com:cloudsdktool before or it is disabled. Enable it by visiting
https://console.developers.google.com/apis/api/speech.googleapis.com/overview?project=google.com:cloudsdktool
then retry. If you enabled this API recently, wait a few minutes for the
action to propagate to our systems and retry.',
domain: 'global',
reason: 'forbidden' } ] }Why is it looking at the wrong project?
How do I set it to look at my project (I have a google project with speech
api enabled)—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#117
from nodejs-docs-samples.
The README no has instructions for setting environment variables in windows.
from nodejs-docs-samples.
Hi @sonanhson , I also have the same problem. I have tried setting the environment variable through the above commands and directly through control panel, but the same error persists. Is there any solution to this problem? Is there any other way I can get the vision API up and running locally?
from nodejs-docs-samples.
it helped me)
from nodejs-docs-samples.
Hi All,
I need your valuable suggestion, I am using google API(Google.Cloud.Speech.V1) for voice dictation and using C# as code behind. Below is the part of Code:
var speech = SpeechClient.Create();
var response = speech.Recognize(new RecognitionConfig()
{
Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
SampleRateHertz = 16000,
LanguageCode = "en",
}, RecognitionAudio.FromFile("audio.raw"));
foreach (var result in response.Results)
{
foreach (var alternative in result.Alternatives)
{
Console.WriteLine(alternative.Transcript);
}
}
but I'm getting exception "Status(StatusCode=PermissionDenied, Detail="Cloud Speech API has not been used in project 19063669187 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/speech.googleapis.com/overview?project=19063669187 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.")".
As one suggestion is given by Hgergely is to run the below code:
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account_file.json
But where I have to run this line of code. I did run in cmd but didn't work. In code behind 'export' keyword is not acceptable.
Please do provide your valuable suggestion with clear details.
Thanks...
from nodejs-docs-samples.
@rajeshray02 use this from command line:
set GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account_file.json
from nodejs-docs-samples.
Why is it looking at the wrong project?
Make sure your
GCLOUD_PROJECT
environment variable is set to your Google project ID.Command prompt:
set GCLOUD_PROJECT=your-project-id set GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account_file.json
Powershell:
$env:GCLOUD_PROJECT="your-project-id" $env:GOOGLE_APPLICATION_CREDENTIALS="/path/to/service_account_file.json"
After all the struggles, I didn't include the $ dollar sign
from nodejs-docs-samples.
export
is not a Windows command. (docs only cater for linux)I got it working by manually adding the env variables in Windows (control panel, system, environment variables)
I am setting it manually, still, I get the same error.
from nodejs-docs-samples.
Still struggling with this myself but @sakthigeek solutions seems to have worked by setting it explicit. Interested to see if anyone else found a solution on Windows by setting it via CMD/PowerShell or through the UI of the control panel
from nodejs-docs-samples.
Related Issues (20)
- bug: multiparts doesn't match to defined types (Part) HOT 3
- run/hello-broken: Fixed resource falls back to a default value failed HOT 2
- run/hello-broken: Broken resource uses the NAME override failed HOT 2
- run/idp-sql: Uncaught error outside test suite failed
- run/idp-sql: Can make a POST request with token failed HOT 1
- Issue with importing the package into a react app HOT 1
- [Policy Bot] found one or more issues with this repository. HOT 1
- SQL sample README suggests using JSON keys against best practices HOT 3
- Steps in Cloud SQL README are out of date and do not work HOT 2
- (gcloud.app.deploy) INVALID_ARGUMENT: Error(s) encountered validating runtime. Runtime nodejs16 is end of support and no longer allowed. Please use the latest Node.js runtime for App Engine Standard.
- Nodejs16 AppEngine is now EOL, please update all samples to nodejs20 the latest AppEngine node version. HOT 2
- run/hello-broken: Fixed resource uses the NAME override failed HOT 1
- Invalid licence headers tripping header-checker CI
- Missing header for FHIR examples HOT 1
- Bug HOT 1
- run/hello-broken: Broken resource uses the NAME override failed
- storage-control: Samples for Managed Folders HOT 1
- run/idp-sql: Can not make a POST request with bad token failed HOT 1
- speech to text v2 INVALID_ARGUMENT: Invalid resource field value in the request HOT 2
- cloud-sql/postgres/knex: should display the default page with connector failed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodejs-docs-samples.