Giter VIP home page Giter VIP logo

Comments (6)

martintoreilly avatar martintoreilly commented on July 23, 2024

@laghee Please could you run the following command from an OSX terminal window? This is the underlying command used to retrieve Keychain passwords. Thanks.
security find-generic-password -s 'ghbackup' -a 'laghee' -w

from python-github-backup.

laghee avatar laghee commented on July 23, 2024

@martintoreilly OK, yep, that command successfully retrieves the token.

from python-github-backup.

martintoreilly avatar martintoreilly commented on July 23, 2024

Thanks. I'm not sure what's going on yet. I've done some digging around and I think the -s option ("service") actually maps to the Where field rather than the Name field in an OSX Keychain password (see help output below for option list). I found a Keychain item where using the Name field for the -s option failed but using the Where field succeeded.

> security find-generic-password --help
find-generic-password: illegal option -- -
Usage: find-generic-password [-a account] [-s service] [options...] [-g] [keychain...]
    -a  Match "account" string
    -c  Match "creator" (four-character code)
    -C  Match "type" (four-character code)
    -D  Match "kind" string
    -G  Match "value" string (generic attribute)
    -j  Match "comment" string
    -l  Match "label" string
    -s  Match "service" string
    -g  Display the password for the item found
    -w  Display only the password on stdout
If no keychains are specified to search, the default search list is used.
        Find a generic password item.

from python-github-backup.

laghee avatar laghee commented on July 23, 2024

Oh, interesting. Yes, if I change the value of the where field to tacos, the command no longer works with ghbackup, but it does work with the new value. (I see the svce attribute is changed to tacos if I run the command without the -w flag.)

from python-github-backup.

einsteinx2 avatar einsteinx2 commented on July 23, 2024

It looks like the error is not the command, that's correct as has been confirmed by running it from the command line.

Turns out it's an exception being thrown on the next line: auth = token + ':' + 'x-oauth-basic'

Here's the exception (I just added a call to raise in the exception handler):

Traceback (most recent call last):
  File "/Users/bbaron/workspacep/python-github-backup/bin/github-backup", line 1127, in <module>
    main()
  File "/Users/bbaron/workspacep/python-github-backup/bin/github-backup", line 1119, in main
    authenticated_user = get_authenticated_user(args)
  File "/Users/bbaron/workspacep/python-github-backup/bin/github-backup", line 591, in get_authenticated_user
    data = retrieve_data(args, template, single_request=True)
  File "/Users/bbaron/workspacep/python-github-backup/bin/github-backup", line 456, in retrieve_data
    return list(retrieve_data_gen(args, template, query_args, single_request))
  File "/Users/bbaron/workspacep/python-github-backup/bin/github-backup", line 412, in retrieve_data_gen
    auth = get_auth(args)
  File "/Users/bbaron/workspacep/python-github-backup/bin/github-backup", line 341, in get_auth
    auth = token + ':' + 'x-oauth-basic'
TypeError: can't concat str to bytes

When I log the token variable, it is in fact bytes not a string, however this is a Python 3 issue only. When run using Python 2, it works as expected.

Adding the following before concatenating the token fixes the issue:

if not PY2:
    token = token.decode('utf-8')

Submitting a PR now :)

from python-github-backup.

einsteinx2 avatar einsteinx2 commented on July 23, 2024

@josegonzalez Looks like my "closes" line in the PR comment didn't automatically close this issue, but it can be closed now that this is merged.

from python-github-backup.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.