Attempting to authorize from cron script leads to repeated reauth attempts

Bug #1045774 reported by Brad Crittenden
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
launchpadlib
Triaged
High
Unassigned

Bug Description

Scenario: A cron script want to log in via a pre-existing credentials file that is passed to the login_with() method as the 'credentials_file' parameter. If by mistake that file does not exist, then the call to login_with will attempt to interactively get authorization via the web browser dance.

In launchpadlib/credentials.py the AuthorizeRequestTokenWithBrowser.make_end_authorize_token method is eventually called. It contains this loop:

        while credentials.access_token is None:
            time.sleep(access_token_poll_time)
            try:
                credentials.exchange_request_token_for_access_token(
                    self.web_root)
                break
            except HTTPError, e:
                if e.response.status == 403:
                    # The user decided not to authorize this
                    # application.
                    raise EndUserDeclinedAuthorization(e.content)
                elif e.response.status == 401:
                    # The user has not made a decision yet.
                    pass
                else:
                    # There was an error accessing the server.
                    print "Unexpected response from Launchpad:"
                    print e

The sleep period is 1 second. The loop never gives up. Eventually mthaddon hunts you down and wakes you up at 5 a.m. on a national holiday to ask that you kill your script that is hammering Launchpad.

Related branches

Brad Crittenden (bac)
Changed in launchpadlib:
status: New → Triaged
Changed in launchpadlib:
importance: Undecided → High
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.