I am following the instructions that are in this link in order to create a Google Cloud storage bucket through Python. https://cloud.google.com/storage/docs/xml-api/gspythonlibrary
I have followed all of the instructions and created a boot file with all of my credentials. I opened the both file and I can see that my gs_access_key_id and gs_secret_access_key are there and the file is saved.
import webapp2
import sys
sys.path.append("/Library/Frameworks/Python.framework/Versions/2.7/lib/py thon2.7/site-packages")
import boto
import gcs_oauth2_boto_plugin
import os
import shutil
import StringIO
import tempfile
import time
GOOGLE_STORAGE = 'gs'
LOCAL_FILE = 'file'
CLIENT_ID = ''
CLIENT_SECRET = ''
gcs_oauth2_boto_plugin.SetFallbackClientIdAndSecret(CLIENT_ID, CLIENT_SECRET)
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.write('Hello world! This should work ! I have been working no this shit all day!')
now = time.time()
CATS_BUCKETS = 'cats-%d' % now
DOGS_BUCKETS = 'cats-%d' % now
project_id = 'name-of-my-bucket'
for name in (CATS_BUCKETS, DOGS_BUCKETS):
uri = boto.storage_uri(name, GOOGLE_STORAGE)
try:
header_values={'x-google-project-id': project_id}
uri.create_bucket()
print 'Successfully created bucket "%s"' %name
except boto.exception.StorageCreateError, e:
print 'Failed to create bucket:', e
app = webapp2.WSGIApplication([
('/', MainHandler)
], debug=True)
However, at the line that it tries to create_bucket, I get an error. I debugged it and it comes back saying that the gs_access_key_id was never found, however it is clearly in my .boto file.
This is the error that I get when I try to run this program in localhost.
File "/Users/LejendVega/Desktop/create-buckets-adrian/main.py", line 48, in get
uri.create_bucket()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/storage_uri.py", line 558, in create_bucket
conn = self.connect()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/storage_uri.py", line 140, in connect
**connection_args)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/gs/connection.py", line 47, in __init__
suppress_consec_slashes=suppress_consec_slashes)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/s3/connection.py", line 191, in __init__
validate_certs=validate_certs, profile_name=profile_name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/connection.py", line 569, in __init__
host, config, self.provider, self._required_auth_capability())
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/auth.py", line 989, in get_auth_handler
'Check your credentials' % (len(names), str(names)))
NoAuthHandlerFound: No handler was ready to authenticate. 3 handlers were checked. ['OAuth2Auth', 'OAuth2ServiceAccountAuth', 'HmacAuthV1Handler'] Check your credentials
All I want to know is why the boto is not recognizing my credentials that are in my boto file.