Comment 2 for bug 293164

Revision history for this message
Markus Korn (thekorn) wrote :

Where exactly is the 401 happening?
In [1]: from launchpadlib.launchpad import Launchpad, STAGING_SERVICE_ROOT

In [2]: launchpad = Launchpad.get_token_and_login('test login on staging', STAGING_SERVICE_ROOT)
The authorization page (https://staging.launchpad.net/+authorize-token?oauth_token=xlnP2n1zN6R9P81TPlHH) should be opening in your browser. After you have authorized this program to access Launchpad on your behalf you should come back here and press <Enter> to finish the authentication process.

---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)

/home/markus/<ipython console> in <module>()

/media/disk-1/lp_api/launnchpadlib/trunk/launchpadlib/launchpad.pyc in get_token_and_login(cls, consumer_name, service_root, cache, timeout, proxy_info)
    151 "here and press <Enter> to finish the authentication "
    152 "process." % authorization_url)
    153 sys.stdin.readline()
    154 credentials.exchange_request_token_for_access_token(web_root)
--> 155 return cls(credentials, service_root, cache, timeout, proxy_info)

/media/disk-1/lp_api/launnchpadlib/trunk/launchpadlib/launchpad.pyc in __init__(self, credentials, service_root, cache, timeout, proxy_info)
     58 # Get the WADL definition.
     59 self._browser = Browser(self.credentials, cache, timeout, proxy_info)
---> 60 self._wadl = self._browser.get_wadl_application(self._root_uri)
     61
     62 # Get the root resource.

/media/disk-1/lp_api/launnchpadlib/trunk/launchpadlib/_browser.pyc in get_wadl_application(self, url)
    227 """GET a WADL representation of the resource at the requested url."""
    228 response, content = self._request(
--> 229 url, media_type='application/vd.sun.wadl+xml')
    230 return Application(str(url), content)
    231

/media/disk-1/lp_api/launnchpadlib/trunk/launchpadlib/_browser.pyc in _request(self, url, data, method, media_type, extra_headers)
    209 # Turn non-2xx responses into exceptions.
    210 if response.status // 100 != 2:
--> 211 raise HTTPError(response, content)
    212 return response, content
    213

HTTPError: HTTP Error 401: Unauthorized

In [3]:

So did the authorization process completed succesfully? Can you see the tokens in your tokens list
Yes this token is on that list