manniru / google-api-python-client

Automatically exported from code.google.com/p/google-api-python-client
Other
0 stars 0 forks source link

Missing property "client_secret" in a client type of "installed". #275

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello all.

I am trying to get access to Google API via Python Client Module. I created 
client-secrets.json file of type "service account" using API Console. It looks 
like this (field values omitted):

{"installed": {
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://accounts.google.com/o/oauth2/token",
    "client_email": "<skipped>@developer.gserviceaccount.com",
    "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/<skipped>@developer.gserviceaccount.com",
    "client_id": "<skipped>.apps.googleusercontent.com",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs"
}}

When function oauth2client/client.py:flow_from_clientsecrets is called with 
this file, the following exception is thrown:

oauth2client.clientsecrets.InvalidClientSecretsError: Missing property 
"client_secret" in a client type of "installed".

What am I doing wrong? The call is as follows:

FLOW = flow_from_clientsecrets(os.path.join(os.path.dirname(__file__), 
CLIENT_SECRETS),
    scope='https://www.googleapis.com/auth/analytics',
    redirect_uri=OOB_CALLBACK_URN,
    )

Original issue reported on code.google.com by partorg....@gmail.com on 10 Jun 2013 at 4:40

GoogleCodeExporter commented 9 years ago
You don't have the key "client_secret" in your dictionary. This is needed to 
mint tokens.

Original comment by dhermes@google.com on 10 Jun 2013 at 8:08

GoogleCodeExporter commented 9 years ago
How do I generate client-secrets.json in this case? Console API gives the only 
option  for "service" apps, and generated client-secrets.json contains no 
"client_secret" key.

Original comment by partorg....@gmail.com on 10 Jun 2013 at 8:12

GoogleCodeExporter commented 9 years ago
You don't want to load flow_from_clientsecrets for a service account. In fact, 
you don't need a flow at all for a service account.

http://google-api-python-client.googlecode.com/hg/docs/epy/oauth2client.client.S
ignedJwtAssertionCredentials-class.html

from oauth2client.client import SignedJwtAssertionCredentials

SERVICE_ACCOUNT_NAME = "<skipped>@developer.gserviceaccount.com"
with open("file_with_keys.p12", "r") as fh:
  PRIVATE_KEY = fh.read()
SCOPE = "THE SCOPES YOU WANT"

credentials = SignedJwtAssertionCredentials(
    SERVICE_ACCOUNT_NAME, PRIVATE_KEY, SCOPE)

Original comment by dhermes@google.com on 10 Jun 2013 at 8:22

GoogleCodeExporter commented 9 years ago

Original comment by jcgregorio@google.com on 5 Aug 2013 at 1:49