keyring file-backend reports backtrace with oauth

Bug #1685962 reported by Nish Aravamudan on 2017-04-24
This bug affects 5 people
Affects Status Importance Assigned to Milestone
python-launchpadlib (Ubuntu)

Bug Description

When bringing the importer back up, I ran into the following:

The authorization page:
should be opening in your browser. Use your browser to authorize
this program to access Launchpad on your behalf.
Waiting to hear from Launchpad about your decision...
Traceback (most recent call last):
  File "./bin/usd", line 17, in <module>
  File "/home/ubuntu/usd-importer/usd/", line 172, in main
  File "/home/ubuntu/usd-importer/usd/", line 1230, in main
    lp = launchpad_login_auth()
  File "/home/ubuntu/usd-importer/usd/", line 47, in launchpad_login_auth
  File "/usr/lib/python3/dist-packages/launchpadlib/", line 544, in login_with
    credential_save_failed, version)
  File "/usr/lib/python3/dist-packages/launchpadlib/", line 351, in _authorize_token_and_login
    credentials = authorization_engine(credentials, credential_store)
  File "/usr/lib/python3/dist-packages/launchpadlib/", line 552, in __call__, self.unique_consumer_id)
  File "/usr/lib/python3/dist-packages/launchpadlib/", line 307, in save
    raise e
  File "/usr/lib/python3/dist-packages/launchpadlib/", line 302, in save
    self.do_save(credentials, unique_consumer_id)
  File "/usr/lib/python3/dist-packages/launchpadlib/", line 384, in do_save
    'launchpadlib', unique_key, serialized)
  File "/usr/lib/python3/dist-packages/keyring/", line 48, in set_password
    _keyring_backend.set_password(service_name, username, password)
  File "/usr/lib/python3/dist-packages/keyring/backends/", line 87, in set_password
    password_encrypted = self.encrypt(password.encode('utf-8'))
AttributeError: 'bytes' object has no attribute 'encode'

cjwatson on IRC suggested this is probably a simple change in launchpadlib:

=== modified file 'src/launchpadlib/'
--- src/launchpadlib/ 2016-08-15 10:32:44 +0000
+++ src/launchpadlib/ 2017-04-24 16:28:46 +0000
@@ -380,7 +380,7 @@ class KeyringCredentialStore(CredentialS
         # this problem by base 64 encoding the serialized value.
         serialized = self.B64MARKER + b64encode(serialized)
- 'launchpadlib', unique_key, serialized)
+ 'launchpadlib', unique_key, serialized.decode('utf8'))

     def do_load(self, unique_key):
         """Retrieve credentials from the keyring."""

which ensures unicode is always passed down, but it needs further testing. It does fix the issue in my particular case.

Related branches

Nish Aravamudan (nacc) wrote :

I asked upstream about this, as well:, and they confirmed that set_password expects a unicode string, not a base64 encoded string.

Scott Moser (smoser) on 2018-03-07
Changed in python-launchpadlib (Ubuntu):
status: New → Confirmed
importance: Undecided → Medium
Changed in python-launchpadlib (Ubuntu Xenial):
status: New → Confirmed
Changed in python-launchpadlib (Ubuntu Artful):
status: New → Confirmed
importance: Undecided → Medium
Changed in python-launchpadlib (Ubuntu Xenial):
importance: Undecided → Medium
Changed in launchpadlib:
status: New → Confirmed
Colin Watson (cjwatson) wrote :

Fixed in launchpadlib 1.10.6.

Changed in launchpadlib:
status: Confirmed → Fix Released
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-launchpadlib - 1.10.6-1

python-launchpadlib (1.10.6-1) unstable; urgency=medium

  [ Colin Watson ]
  * Team upload.
  * New upstream release:
    - Fix saving of credentials in python3 with gnome-keyring (closes:
      #882166, LP: #1685962).
  * Move VCS to

  [ Ondřej Nový ]
  * d/copyright: Use https protocol in Format field

 -- Colin Watson <email address hidden> Thu, 08 Mar 2018 11:43:11 +0000

Changed in python-launchpadlib (Ubuntu Bionic):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

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