Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #32692 > unrolled thread

Google spreadsheets - getting started

Started byMark Carter <alt.mcarter@gmail.com>
First post2012-11-03 03:20 -0700
Last post2012-11-03 05:40 -0700
Articles 3 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Google spreadsheets - getting started Mark Carter <alt.mcarter@gmail.com> - 2012-11-03 03:20 -0700
    Re: Google spreadsheets - getting started Mark Carter <alt.mcarter@gmail.com> - 2012-11-03 04:03 -0700
      Re: Google spreadsheets - getting started Mark Carter <alt.mcarter@gmail.com> - 2012-11-03 05:40 -0700

#32692 — Google spreadsheets - getting started

FromMark Carter <alt.mcarter@gmail.com>
Date2012-11-03 03:20 -0700
SubjectGoogle spreadsheets - getting started
Message-ID<7d42e442-15cb-47e9-b1d1-48ee334648c8@googlegroups.com>
I want to mess around with my online Google spreadsheets from my Linux box programmatically. I am TOTALLY confused.

I've got gdata installed, and it appears that the best way to access the spreadsheets is to authenticate with Oauth2.

Here's the main thing: how do I get an Oauth2 key to use with Google spreadsheets?

I obtain a "p12" key, but I don't know if that's for something completely different.

[toc] | [next] | [standalone]


#32693

FromMark Carter <alt.mcarter@gmail.com>
Date2012-11-03 04:03 -0700
Message-ID<4f36c90c-1d85-44f7-a642-9bc7d3b9a276@googlegroups.com>
In reply to#32692
OK, maybe the p12 file is useful after all (?) I've got the following code:

import gdata

tokenfile = "my-privatekey.p12"
f = open(tokenfile, 'r')
blob = f.read()
f.close()
token = gdata.gauth.token_from_blob(blob)

When I run that I get:
Traceback (most recent call last):
  File "/home/mcarter/wapp.py", line 8, in <module>
    token = gdata.gauth.token_from_blob(blob)
AttributeError: 'module' object has no attribute 'gauth'

I guess I'm using a newer version of gdata (2.0.14). 

None of this makes any sense.

[toc] | [prev] | [next] | [standalone]


#32694

FromMark Carter <alt.mcarter@gmail.com>
Date2012-11-03 05:40 -0700
Message-ID<cebb8362-9417-4dfd-b7ac-fb677a8d75ee@googlegroups.com>
In reply to#32693
OK, the story so far:


import gdata
import gdata.auth
import gdata.gauth
import gdata.docs.service
import OpenSSL.crypto

tokenfile = "privatekey.p12"
#f = open(tokenfile, 'r')
#blob = f.read()
#f.close()
#if blob:
p12 = OpenSSL.crypto.load_pkcs12(file(tokenfile, 'rb').read(), 'notasecret')
print p12.get_certificate() 
    
#token = gdata.gauth.token_from_blob(p12)
#print "token: ", token

gd_client = gdata.docs.service.DocsService()
#gd_client.SetOAuthToken(token)
gd_client.SetOAuthToken(p12)

feed = gd_client.GetDocumentListFeed() # line 22
for entry in feed.entry:
      print entry.title.text.encode('UTF-8')

print "Finished"



It baulks as follows:
/usr/bin/python -u  "/home/mcarter/wapp.py"
<X509 object at 0x7fccc0917a50>
Traceback (most recent call last):
  File "/home/mcarter/wapp.py", line 22, in <module>
    feed = gd_client.GetDocumentListFeed()
  File "/usr/lib/pymodules/python2.7/gdata/docs/service.py", line 259, in GetDocumentListFeed
    return self.QueryDocumentListFeed(uri)
  File "/usr/lib/pymodules/python2.7/gdata/docs/service.py", line 238, in QueryDocumentListFeed
    return self.Get(uri, converter=gdata.docs.DocumentListFeedFromString)
  File "/usr/lib/pymodules/python2.7/gdata/service.py", line 1068, in Get
    headers=extra_headers)
  File "/usr/lib/pymodules/python2.7/atom/__init__.py", line 92, in optional_warn_function
    return f(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/atom/service.py", line 184, in request
    return auth_token.perform_request(self.http_client, operation, url, 
AttributeError: 'PKCS12' object has no attribute 'perform_request'


What??

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web