GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Can not use 'my-api-key' on google.cloud.translate API. translate may support OAuth2 now? · Issue #2903 · googleapis/google-cloud-python

Can not use 'my-api-key' on google.cloud.translate API. translate may support OAuth2 now? #2903

New issue
Copy link
New issue
Copy link
Closed
Closed
Can not use 'my-api-key' on google.cloud.translate API. translate may support OAuth2 now?#2903
Copy link
Assignees
daspecster
Labels
api: translationIssues related to the Cloud Translation API API.

Description

@hidehara
hidehara
opened on Dec 28, 2016
Issue body actions

I'm trying to use translate API with API-Key.
But I got error when I follow instruction on instruction of following:

Translate Doc mentioned how to use it:

  • https://googlecloudplatform.github.io/google-cloud-python/stable/translate-usage.html

Error:

client = translate.Client('my API Key is given')
...
DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or
explicitly create credential and re-run the application. For more
information, please see
https://developers.google.com/accounts/docs/application-default-credentials.

I just guess , now only OAuth2 is supported by translate API. Because of some information. Should the Doc updates or am I wrong ?

Env:

  • google-cloud-translate (0.22.0)
  • Python 2.7.6 on Ubuntu 14.04
  • pip 9.0.1

Some information:

On Translate Client Document,

  • https://googlecloudplatform.github.io/google-cloud-python/stable/translate-client.html

And help(translate.Client)

Help on class Client in module google.cloud.translate.client:

class Client(google.cloud.client.Client)
| Client to bundle configuration needed for API requests.
|
...
| :type credentials: :class:oauth2client.client.OAuth2Credentials
| :param credentials: (Optional) The OAuth2 Credentials to use for the
| connection owned by this client. If not passed (and
| if no http object is passed), falls back to the
| default inferred from the environment.
...
| Methods defined here:
|
| init(self, target_language='en', credentials=None, http=None)

Activity

  1. daspecster
    added
    docs
    api: translationIssues related to the Cloud Translation API API.
    on Dec 28, 2016
  2. daspecster commented on Dec 28, 2016

    @daspecster
    daspecster
    on Dec 28, 2016
    Contributor
    More actions

    @hidehara I'm sorry you ran into trouble with this!
    I'll get a PR to update the docs going right now.

    Support for the API key was removed via #2823 and released in 0.22.0.

    The prefered way to authenticate is with service accounts. Which we do have docs explaining how to set that up here: https://googlecloudplatform.github.io/google-cloud-python/stable/google-cloud-auth.html.

    Reacted by Hidekz Hara
  3. hidehara commented on Dec 28, 2016

    @hidehara
    hidehara
    on Dec 28, 2016
    Author
    More actions

    @daspecster Thanks for nice reply.

    I have a question , why API-Key was removed ?
    Is that based on Google Cloud Translate life cycle OR just new policy of google-cloud-python ?

    If you have any information, please let's me know.

    I read #2823 , so I understand that I should use OAuth2 from 0.22.0.

  4. daspecster commented on Dec 28, 2016

    @daspecster
    daspecster
    on Dec 28, 2016
    Contributor
    More actions

    Anytime!

    @hidehara, I believe that it was always intended that Translate use Service Accounts.
    Only recently was Service Account support added to the upstream Translate service.

    @jonparrott or @dhermes would know more about it I'm sure.

    Reacted by Hidekz Hara
  5. hidehara commented on Dec 28, 2016

    @hidehara
    hidehara
    on Dec 28, 2016
    Author
    More actions

    @daspecster , Oh, sorry about type of Account.
    I succeed to use translate with 'Service Accounts' by using following sytle.

    export GOOGLE_APPLICATION_CREDENTIALS="/path/to/keyfile.json"

    I confused to use which type of Account , cause of help(translate.Client). But now I'm OK to use Service Account.

    If Google will still support API-Key , It's easy & best way for me (;
    Thanks for kind information.

  6. dhermes commented on Dec 28, 2016

    @dhermes
    dhermes
    on Dec 28, 2016
    Contributor
    More actions

    @hidehara We elected to drop support for API key auth as a "library decision" but the backend still supports it. The auth doc linked to by @daspecster should have everything needed to authenticate. It's incorrect to say you must use a service account, you can also use OAuth 2.0 based credentials for user accounts. For deployed applications however, we strongly recommend the use of a service account.

    The release listed the dropped feature, though maybe this wasn't clear enough?

    Reacted by Hidekz Hara
  7. daspecster
    closed this as completedin #2904on Dec 28, 2016
  8. hidehara commented on Jan 6, 2017

    @hidehara
    hidehara
    on Jan 6, 2017
    Author
    More actions

    @dhermes Thanks for above. I'm clear now.

    I got background of "library decision" and the backend still supports API Key auth.
    I succeed to use a service account, so I may implement with it.

  9. JustinBeckwith
    assigned
    daspecster
    on Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @daspecster
    daspecster

Labels

api: translationIssues related to the Cloud Translation API API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.