Error with OAuth in Google Data Protocol Client Libraries

When I tested the code in OAuth in the Google Data Protocol Client Libraries ( http://code.google.com/apis/gdata/docs/auth/oauth.html ), I always got the following error. Can anyone give me a hint?

Error code:

  File "D:\PROJ\GAE\proj2\proj2.py", line 262, in get
    return self.redirect(auth_url)
  File "C:\DEV\google_appengine\v1.4.2\google\appengine\ext\webapp\__init__.py", line 380, in redirect
    absolute_url = urlparse.urljoin(self.request.uri, uri)
  File "C:\DEV\Python\v2.5.4\lib\urlparse.py", line 253, in urljoin
    urlparse(url, bscheme, allow_fragments)
  File "C:\DEV\Python\v2.5.4\lib\urlparse.py", line 154, in urlparse
    tuple = urlsplit(url, scheme, allow_fragments)
  File "C:\DEV\Python\v2.5.4\lib\urlparse.py", line 193, in urlsplit
    i = url.find(':')
AttributeError: 'Uri' object has no attribute 'find'

Here is the code that I want to get for contact information for Google:

class Test(webapp.RequestHandler):
    def get(self):
        client = gdata.contacts.client.ContactsClient(source = 'www.mydomainname.com')
        callback_url = 'http://%s/test2' % self.request.host

        request_token = client.GetOAuthToken(['http://www.google.com/m8/feeds/'],
                                                     callback_url,
                                                     GOOGLE_KEY,
                                                     GOOGLE_SECRET)

        gdata.gauth.AeSave(request_token, 'request_token')

        auth_url = request_token.generate_authorization_url(google_apps_domain = None)
        return self.redirect(auth_url) #Error?!

Thanks in advance!

+3
source share
1 answer

The auth_url created is not a string.

Just do:

return self.redirect(str(auth_url))

and it will work.

+3
source

Source: https://habr.com/ru/post/1793547/


All Articles