2016-06-08 7 views
1

Ich teste gerade google cloud storage json API, um meine Bucket-Objekte aufzulisten. Ich habe these Anweisungen zum Erstellen von Standardanmeldeinformationen gefolgt. Und ich habe auch GCS json API auf meinem Projekt dashborad aktiviert .. Aber noch zeigt es ApplicationDefaultCredentialsError Fehler ..Google Cloud Storage-Bucket-Objekte können nicht über die JSON-API abgerufen werden

$ echo $GOOGLE_APPLICATION_CREDENTIALS 
/home/gemini/Documents/foo-staging-dfab9cc17b65.json 

$ python list_objects.py foo.staging.com 
Traceback (most recent call last): 
    File "list_objects.py", line 90, in <module> 
    main(args.bucket) 
    File "list_objects.py", line 78, in main 
    print(json.dumps(get_bucket_metadata(bucket), indent=2)) 
    File "list_objects.py", line 50, in get_bucket_metadata 
    service = create_service() 
    File "list_objects.py", line 39, in create_service 
    credentials = GoogleCredentials.get_application_default() 
    File "/usr/local/lib/python2.7/dist-packages/oauth2client/client.py", line 1398, in get_application_default 
    return GoogleCredentials._get_implicit_credentials() 
    File "/usr/local/lib/python2.7/dist-packages/oauth2client/client.py", line 1388, in _get_implicit_credentials 
    raise ApplicationDefaultCredentialsError(ADC_HELP_MSG) 
oauth2client.client.ApplicationDefaultCredentialsError: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information. 
+0

unter Antwort tut der Job .. Gibt es einen anderen Weg, die Variable zur Laufzeit verfügbar zu machen? –

Antwort

1

fand ich die Art und Weise env Variable Python zur Laufzeit für das Bestehen. Ich muss laufen,

$ GOOGLE_APPLICATION_CREDENTIALS="/home/gemini/Documents/foo-staging-dfab9cc17b65.json" python list_objects.py <bucket-name> 
Verwandte Themen