google / gdata-python-client

444 stars 228 forks source link

SitesFeedSummary example doesn't work #31

Open sallyruthstruik opened 9 years ago

sallyruthstruik commented 9 years ago

Here is output:

/home/stas/env/wmt_scrapper/bin/python /home/stas/PycharmProjects/wmt_scrapper/gdata-python-client/samples/webmastertools/SitesFeedSummary.py
Please enter your username: ****
/usr/lib/python2.7/getpass.py:83: GetPassWarning: Can not control echo on the terminal.
  passwd = fallback_getpass(prompt, stream)
Warning: Password input may be echoed.
Password: ****

Logging in
Retrieving Sites feed
Traceback (most recent call last):
  File "/home/stas/PycharmProjects/wmt_scrapper/gdata-python-client/samples/webmastertools/SitesFeedSummary.py", line 42, in <module>
    feed = client.GetSitesFeed()
  File "/home/stas/env/wmt_scrapper/local/lib/python2.7/site-packages/gdata/webmastertools/service.py", line 85, in GetSitesFeed
    return self.Get(uri, converter=converter)
  File "/home/stas/env/wmt_scrapper/local/lib/python2.7/site-packages/gdata/service.py", line 1107, in Get
    'reason': server_response.reason, 'body': result_body}
gdata.service.RequestError: {'status': 401, 'body': '<HTML>\n<HEAD>\n<TITLE>Authorization required</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Authorization required</H1>\n<H2>Error 401</H2>\n</BODY>\n</HTML>\n', 'reason': 'Authorization required'}

Also, when I try to use oauth authentication I also get's error:

#-*- coding: utf-8 -*-
from wmt_scrapper.google_api import GoogleApi

__author__ = 'stas'

import gdata.webmastertools.service

client = gdata.webmastertools.service.GWebmasterToolsService()

def request(*a, **k):
    stream = client.request(*a, **k)
    out = stream.read()
    stream.close()

    return out

gapi = GoogleApi()

gapi.credentials.authorize(client)

print request('GET', "https://www.google.com/webmasters/tools/gwt/SITE_LIST?hl=en&authuser=1")

returns

Traceback (most recent call last):
  File "/home/stas/PycharmProjects/wmt_scrapper/gwtd/test.py", line 21, in <module>
    print request('GET', "https://www.google.com/webmasters/tools/gwt/SITE_LIST?hl=en&authuser=1")
  File "/home/stas/PycharmProjects/wmt_scrapper/gwtd/test.py", line 11, in request
    stream = client.request(*a, **k)
  File "/home/stas/env/wmt_scrapper/local/lib/python2.7/site-packages/oauth2client/client.py", line 562, in new_request
    redirections, connection_type)
  File "/home/stas/env/wmt_scrapper/local/lib/python2.7/site-packages/atom/__init__.py", line 92, in optional_warn_function
    return f(*args, **kwargs)
TypeError: request() takes at most 6 arguments (7 given)
ryeager315 commented 9 years ago

I am getting the same error...exactly.