title: Cannot access google spreadsheet
body: <p>I am trying to learn Google's gdata Python API, and trying to get initial access to a test spreadsheet in my drive. heres the code I am using as a test:</p>
  
  <pre><code>from oauth2client.service_account import ServiceAccountCredentials
  import gdata.spreadsheets.client
  
  # 認証に必要な情報
  client_email = "59508263769-compute@developer.gserviceaccount.com" # 手順2で発行されたメールアドレス
  with open("C:\Users\User2\Downloads\My Project-e7c4abb055f3.p12") as f: private_key = f.read() # 手順2で発行された秘密鍵
  
  # 認証情報の作成
  scope = ["https://spreadsheets.google.com/feeds"]
  credentials = ServiceAccountCredentials(client_email, private_key,
      scope=scope)
  
  # スプレッドシート用クライアントの準備
  client = gdata.spreadsheets.client.SpreadsheetsClient()
  
  # OAuth2.0での認証設定
  auth_token = gdata.gauth.OAuth2TokenFromCredentials(credentials)
  auth_token.authorize(client)
  
  # ---- これでライブラリを利用してスプレッドシートにアクセスできる ---- #
  
  # ワークシートの取得
  sheets = client.get_worksheets("1RRajoMlKP2plSnE12dt_BqVbk9TihCpDpumvhF-y7vM") # スプレッドシートIDを指定
  for sheet in sheets.entry:
      print sheet.get_worksheet_id(), sheet.title
  </code></pre>
  
  <p>I'm basing it off of this tutorial <a href="http://qiita.com/koyopro/items/d8d56f69f863f07e9378" rel="nofollow">http://qiita.com/koyopro/items/d8d56f69f863f07e9378</a> (sorry its all in Japanese).</p>
  
  <p>The method this guy is proposing is using something called a p12 as a key(?) to gain access to things in your Google Apps when creating OAuth2 credentials. Then sharing your spread sheet to an @developer email address generated.</p>
  
  <p>I run this code and it's fine, until it hits</p>
  
  <pre><code>sheets = client.get_worksheets("1RRajoMlKP2plSnE12dt_BqVbk9TihCpDpumvhF-y7vM") # スプレッドシートIDを指定
  </code></pre>
  
  <p>And this gives me the following errors:</p>
  
  <pre><code>Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32
  Type "copyright", "credits" or "license()" for more information.
  &gt;&gt;&gt; 
  ========= RESTART: C:\Users\User2\Documents\googlePythonTest04_01.py =========
  
  Traceback (most recent call last):
    File "C:\Users\User2\Documents\googlePythonTest04_01.py", line 24, in &lt;module&gt;
      sheets = client.get_worksheets("1RRajoMlKP2plSnE12dt_BqVbk9TihCpDpumvhF-y7vM") # ã‚¹ãƒ—ãƒ¬ãƒƒãƒ‰ã‚·ãƒ¼ãƒˆIDã‚’æŒ‡å®š
    File "C:\Python27\lib\site-packages\gdata\spreadsheets\client.py", line 108, in get_worksheets
      **kwargs)
    File "C:\Python27\lib\site-packages\gdata\client.py", line 640, in get_feed
      **kwargs)
    File "C:\Python27\lib\site-packages\gdata\client.py", line 267, in request
      uri=uri, auth_token=auth_token, http_request=http_request, **kwargs)
    File "C:\Python27\lib\site-packages\atom\client.py", line 122, in request
      return self.http_client.request(http_request)
    File "C:\Python27\lib\site-packages\gdata\gauth.py", line 1332, in new_request
      refresh_response = self._refresh(request_orig)
    File "C:\Python27\lib\site-packages\gdata\gauth.py", line 1473, in _refresh
      self.credentials._refresh(httplib2.Http().request)
    File "C:\Python27\lib\site-packages\oauth2client-2.2.0-py2.7.egg\oauth2client\client.py", line 873, in _refresh
      self._do_refresh_request(http_request)
    File "C:\Python27\lib\site-packages\oauth2client-2.2.0-py2.7.egg\oauth2client\client.py", line 900, in _do_refresh_request
      body = self._generate_refresh_request_body()
    File "C:\Python27\lib\site-packages\oauth2client-2.2.0-py2.7.egg\oauth2client\client.py", line 1611, in _generate_refresh_request_body
      assertion = self._generate_assertion()
    File "C:\Python27\lib\site-packages\oauth2client-2.2.0-py2.7.egg\oauth2client\service_account.py", line 396, in _generate_assertion
      key_id=self._private_key_id)
    File "C:\Python27\lib\site-packages\oauth2client-2.2.0-py2.7.egg\oauth2client\crypt.py", line 97, in make_signed_jwt
      signature = signer.sign(signing_input)
  AttributeError: 'str' object has no attribute 'sign'
  &gt;&gt;&gt; 
  </code></pre>
  
  <p>According to this tutorial, the last print command should return</p>
  
  <pre><code>od6 &lt;ns0:title xmlns:ns0="http://www.w3.org/2005/Atom"&gt;&amp;#12471;&amp;#12540;&amp;#12488;1&lt;/ns0:title&gt;0
  </code></pre>
  
  <p>But its giving me this string/sign error.</p>
  
  <p>Am I doing something wrong? Or did the API change on this get_worksheets command? I know a lot of things might have changed since this tutorial was written since I had to change the "import SignedJwtAssertionCredentials" to "import ServiceAccountCredentials" because apparently SignedJwtAssertionCredentials no longer exists (according to this thread: <a href="https://github.com/google/oauth2client/issues/401" rel="nofollow">https://github.com/google/oauth2client/issues/401</a>)</p>
  
  <p>I know I could be using this other much simpler "gspread" API, but my understanding is that you can't actually edit a spreadsheet with it so I am just going with gdata.</p>
  
  <p>Thank you so much in advance.</p>