Forum Archive

StaSh github credentials

maboesanman

I'm new to stash, and I can't figure out where to put my github credentials, as it seems git and gh both assume you've already input them somehow. Where are the credentials stored?

JonB

I have been meaning to push this change to gh:

def setup_gh():
    keychainservice='stash.git.github.com'
    try:
        user = dict(keychain.get_services())[keychainservice]
    except:
        user=input('github username? ')
    try:
        pw = keychain.get_password(keychainservice, user)
    except:
        pw=console.secure_input('Password?')
    g=Github(user,pw)
    u=g.get_user()

    return g, u
maboesanman

that looks like its reading, not storing. Am I missing something?

JonB

oh you are right... should be storing to that key as well.

btw: I am not sure if current stash git supports clone or pull using passwords... I think probably not. You could try:

git clone https://username:pass@github.com/user/repo.git

but for various reasons this might not work until we replace the existing dulwich implementation. ssh should work for everything, you should probably use ssh if you can, but be aware that ssh push essentially is a force push, and will overwrite github history

JonB

keychain.set_password(keychainservice, user, pw)

will store the creds

msteen

I’m a stash noob so apologies if I’m missing something obvious. I’ve got the same issue as @maboesanman. I’m trying to follow @JonB’s advice, but when I type:

keychain.setpassword()

on the StaSh command line, I get the response:

stash: keychain.set_password(): command not found

I’m clearing missing something. Thanks for any help.

dgelessus

keychain.setpassword is a Python function in the keychain module provided by Pythonista. You need to use it in Pythonista's Python console, not in Stash. (Also don't forget to run import keychain first, so you can use the keychain module in the console.)