trouble to get start with Speech API

644 views
Skip to first unread message

Ying Liu

unread,
May 8, 2017, 9:53:24 PM5/8/17
to Google Cloud Developers
I am testing the Speech API. By following the quick start instructions, I created a speech api project, and created a service account with it, and enabled billing. I have trouble to get authenticated.

(1)
gcloud auth activate-service-account --key-file=SpeechApi-72564282d5af.json
Activated service account credentials for: [serviceacco...@speechapi-166721.iam.gserviceaccount.com]

(2)
gcloud auth application-default print-access-token
ya29.GltFBIkvHR1DT_EKT5QdQ8g4_x1uS-UGUTpbheHaup9nloeD2A6Ql7fPSMlLKqt30JGJABvFf3JoarYXqCO3W5DHWQo4Pbe8NduXijtk-OxnDijcqC3VUrT2Hfm-

(3)
curl -s -k -H "Content-Type: application/json" -H "Authorization: Bearer access_token" https://speech.googleapis.com/v1/speech:recognize -d @sync-request.json
{
  "error": {
    "code": 401,
    "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED"
  }
}

Can you help me on this? Thank you very much!

Ying

Zachary Newman

unread,
May 9, 2017, 9:06:34 AM5/9/17
to Ying Liu, Google Cloud Developers
Two points:

- You probably shouldn't share your access token with public groups like this one; it will allow anybody who sees it to use your account. Fortunately, access tokens are short-lived (expire after ~1hr), so there's nothing more you need to do, but be careful in the future.

- If I'm reading correctly, you put a literal `access_token` in the curl request; you need to substitute your actual access token.

Hope that helps.

On Mon, May 8, 2017 at 8:59 PM, Ying Liu <yingy...@gmail.com> wrote:
I am testing the Speech API. By following the quick start instructions, I created a speech api project, and created a service account with it, and enabled billing. I have trouble to get authenticated.

(1)
gcloud auth activate-service-account --key-file=SpeechApi-72564282d5af.json
Activated service account credentials for: [serviceaccountkey-ying@speechapi-166721.iam.gserviceaccount.com]

(2)
gcloud auth application-default print-access-token
ya29.GltFBIkvHR1DT_EKT5QdQ8g4_x1uS-UGUTpbheHaup9nloeD2A6Ql7fPSMlLKqt30JGJABvFf3JoarYXqCO3W5DHWQo4Pbe8NduXijtk-OxnDijcqC3VUrT2Hfm-

(3)
curl -s -k -H "Content-Type: application/json" -H "Authorization: Bearer access_token" https://speech.googleapis.com/v1/speech:recognize -d @sync-request.json
{
  "error": {
    "code": 401,
    "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED"
  }
}

Can you help me on this? Thank you very much!

Ying

--
You received this message because you are subscribed to the Google Groups "Google Cloud Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-dev/80c9fe79-86f9-46cc-975e-42da0add846d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

sudharshan vaddi

unread,
Jun 7, 2017, 11:47:20 AM6/7/17
to Google Cloud Developers, yingy...@gmail.com
I added access token request to my command, still the same error, I am unable to figure out the solution.

Any Help?

See my Command

curl -s -k -H "Content-Type: application/json"     -H "Authorization: Bearer **blah_blah**"     https://speech.googleapis.com/v1/speech:recognize     -d @response.json

On Tuesday, 9 May 2017 18:36:34 UTC+5:30, Zachary Newman wrote:
Two points:

- You probably shouldn't share your access token with public groups like this one; it will allow anybody who sees it to use your account. Fortunately, access tokens are short-lived (expire after ~1hr), so there's nothing more you need to do, but be careful in the future.

- If I'm reading correctly, you put a literal `access_token` in the curl request; you need to substitute your actual access token.

Hope that helps.
On Mon, May 8, 2017 at 8:59 PM, Ying Liu <yingy...@gmail.com> wrote:
I am testing the Speech API. By following the quick start instructions, I created a speech api project, and created a service account with it, and enabled billing. I have trouble to get authenticated.

(1)
gcloud auth activate-service-account --key-file=SpeechApi-72564282d5af.json
Activated service account credentials for: [serviceacco...@speechapi-166721.iam.gserviceaccount.com]

(2)
gcloud auth application-default print-access-token
ya29.GltFBIkvHR1DT_EKT5QdQ8g4_x1uS-UGUTpbheHaup9nloeD2A6Ql7fPSMlLKqt30JGJABvFf3JoarYXqCO3W5DHWQo4Pbe8NduXijtk-OxnDijcqC3VUrT2Hfm-

(3)
curl -s -k -H "Content-Type: application/json" -H "Authorization: Bearer access_token" https://speech.googleapis.com/v1/speech:recognize -d @sync-request.json
{
  "error": {
    "code": 401,
    "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED"
  }
}

Can you help me on this? Thank you very much!

Ying

--
You received this message because you are subscribed to the Google Groups "Google Cloud Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-d...@googlegroups.com.

Divyesh Patel

unread,
Feb 10, 2018, 12:01:51 PM2/10/18
to Google Cloud Developers
hi did you solve the problem ? coz i get the same error 
Reply all
Reply to author
Forward
0 new messages