Merge lp:~leonardr/launchpadlib/handle-unknown-token into lp:launchpadlib
Status: | Merged |
---|---|
Merge reported by: | Leonard Richardson |
Merged at revision: | not available |
Proposed branch: | lp:~leonardr/launchpadlib/handle-unknown-token |
Merge into: | lp:launchpadlib |
Diff against target: |
64 lines (+22/-2) 4 files modified
src/launchpadlib/NEWS.txt (+6/-0) src/launchpadlib/__init__.py (+1/-1) src/launchpadlib/launchpad.py (+2/-1) src/launchpadlib/tests/test_http.py (+13/-0) |
To merge this branch: | bzr merge lp:~leonardr/launchpadlib/handle-unknown-token |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Benji York (community) | code | Approve | |
Review via email: mp+51563@code.launchpad.net |
Description of the change
Sometimes a launchpadlib client will present Launchpad with an OAuth access token that's expired or invalid. Launchpad sends a 401 response code and an error message. launchpadlib recognizes these error messages and knows to fetch a new access token when it gets one. But it doesn't recognize the error message "Unknown access token", which is sent when a token is valid but Launchpad simply doesn't have it in its database.
Right now access tokens are kept in the Launchpad database permanently, so in normal usage this error only shows up on staging. You'll get it if you get an access token, then the staging database is wiped, then you try to use the token.
This branch makes launchpadlib request a new token when this error occurs. It's got a unit test and I've also tested it manually.
Looks good.