Well, I have made a little progress 
: 
https://developers.google.com/api-client-library/python/guide/google_app_engine#Credentials

But, now the only question is how to get the modules:

<type 'exceptions.ImportError'> No module named appengine.api



El jueves, 26 de febrero de 2015, 8:48:46 (UTC+1), Jacinto Parga escribió:
>
> Hi, 
>
> I am using Google Cloud Storage (GCS) with web2py.
>
> I've implemented ( 
> https://cloud.google.com/storage/docs/json_api/v1/json-api-python-samples 
> ) it works fine in localhost or in systems where you can write in the 
> filesystem.
>
> But in Google App Engine (GAE) you can not write in the filesystem so it 
> doesn't create nor update *sample.dat*
>
>  # If the credentials don't exist or are invalid run through the native client
>   # flow. The Storage object will ensure that if successful the good
>   # credentials will get written back to the file.
>   storage = file.Storage('sample.dat')
>   credentials = storage.get()
>   if credentials is None or credentials.invalid:
>     credentials = tools.run_flow(FLOW, storage, flags)
>
>   # Create an httplib2.Http object to handle our HTTP requests and authorize 
> it
>
>   # with our good Credentials.
>   http = httplib2.Http()
>   http = credentials.authorize(http)
>
>   # Construct the service object for the interacting with the Cloud Storage 
> API.
>   service = discovery.build('storage', _API_VERSION, http=http)
>
>
> The result is that anytime I deploy it in GAE it works fine until the 
> *token* stored in *sample.dat * expires. As soon as it expires it cannot 
> update the file so the access is revoked.
>
> Maybe I can change the file *sample.dat*  for a variable stored in a 
> table, something like this. 
>
> db.define_table('t_sample',
>     Field('f_sampledat', type='text',  label=T('Mensaje')))
>
> But I haven't found how to do it right, how to store the content of 
> sample.dat and to access it in the same way. Any suggestion.
>
> The sample.dat file is like this:
>
> {"_module": "oauth2client.client", "token_expiry": "2015-02-25T20:17:48Z",
>  "access_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 
> "token_uri": "https://accounts.google.com/o/oauth2/token";, "invalid": 
> false, "token_response": {"access_token": 
> "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "token_type":
>  "Bearer", "expires_in": 3600}, "client_id": "
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com", "id_token"
> : null, "client_secret": "xxxxxxxxxxxxxxxxxxxxxxx", "revoke_uri": "
> https://accounts.google.com/o/oauth2/revoke";, "_class": 
> "OAuth2Credentials", "refresh_token": 
> "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 
> "user_agent": null}
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to