keyring file-backend reports backtrace with oauth

Bug #1685962 reported by Nish Aravamudan
38
This bug affects 5 people
Affects Status Importance Assigned to Milestone
launchpadlib
Fix Released
Undecided
Unassigned
python-launchpadlib (Ubuntu)
Fix Released
Medium
Unassigned
Xenial
Confirmed
Medium
Unassigned
Artful
Confirmed
Medium
Unassigned
Bionic
Fix Released
Medium
Unassigned

Bug Description

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

The authorization page:
 (<ELIDED>)
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>
    main()
  File "/home/ubuntu/usd-importer/usd/__main__.py", line 172, in main
    args.func(args)
  File "/home/ubuntu/usd-importer/usd/importer.py", line 1230, in main
    lp = launchpad_login_auth()
  File "/home/ubuntu/usd-importer/usd/source_information.py", line 47, in launchpad_login_auth
    version=_lp_api_version)
  File "/usr/lib/python3/dist-packages/launchpadlib/launchpad.py", line 544, in login_with
    credential_save_failed, version)
  File "/usr/lib/python3/dist-packages/launchpadlib/launchpad.py", line 351, in _authorize_token_and_login
    credentials = authorization_engine(credentials, credential_store)
  File "/usr/lib/python3/dist-packages/launchpadlib/credentials.py", line 552, in __call__
    credential_store.save(credentials, self.unique_consumer_id)
  File "/usr/lib/python3/dist-packages/launchpadlib/credentials.py", line 307, in save
    raise e
  File "/usr/lib/python3/dist-packages/launchpadlib/credentials.py", line 302, in save
    self.do_save(credentials, unique_consumer_id)
  File "/usr/lib/python3/dist-packages/launchpadlib/credentials.py", line 384, in do_save
    'launchpadlib', unique_key, serialized)
  File "/usr/lib/python3/dist-packages/keyring/core.py", line 48, in set_password
    _keyring_backend.set_password(service_name, username, password)
  File "/usr/lib/python3/dist-packages/keyring/backends/file.py", 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/credentials.py'
--- src/launchpadlib/credentials.py 2016-08-15 10:32:44 +0000
+++ src/launchpadlib/credentials.py 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)
         keyring.set_password(
- '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

Revision history for this message
Nish Aravamudan (nacc) wrote :

I asked upstream about this, as well: https://github.com/jaraco/keyrings.alt/issues/23, and they confirmed that set_password expects a unicode string, not a base64 encoded string.

Scott Moser (smoser)
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
Revision history for this message
Colin Watson (cjwatson) wrote :

Fixed in launchpadlib 1.10.6.

Changed in launchpadlib:
status: Confirmed → Fix Released
Revision history for this message
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 salsa.debian.org.

  [ 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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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