How can I erase the GitHub Token set by Travis CI in osxkeychain

Hi,

I would like to do some testing that relies on my person GitHub token which should be stored in osxkeychain. I can do it by git "credential-osxkeychain" store, but it appears that on Travis CI even I set it, git will still use another token, which I believe is set by Travis CI before my script is run.

I tried to do a echo "host=github.com\\nprotocol=https" | git credential-osxkeychain get to check if there are any GitHub tokens set beforehand by Travis CI. But nothing shows up. Same command run on my laptop shows my GitHub Token.

Can anyone here give me some explanation on some internals of how Travis CI store the GitHub token? git config(local and global) shows that credential.helper=osxkeychain. So I am really confused as to why I don’t see any GitHub tokens stored in the keychain.
Some other workarounds will also be appreciated.

Unless you link to the build(s) in question, it’s really hard to tell what exactly you’re talking about.

Hi,

Since the build is on a private repo, the link won’t be much helpful…
But I can give more background on my question:

My build uses MacOS env and will need to put a custom GitHub Token in osxkeychain and do test using this specific token. The osxkeychain basically is a credential helper that will save you GitHub credentials safely using MaxOS’s keychain and allows you connect to GitHub via https(such as git clone) without the need to give password again. Check here for more info: https://help.github.com/en/articles/caching-your-github-password-in-git

The command I use to store my custom GitHub Token is:
remove existing token:
printf "protocol=https\nhost=%s\nusername=%s\n" "$host" "$username" | git "credential-osxkeychain" erase
add new ones(my customize token):
printf "protocol=https\nhost=%s\nusername=%s\npassword=%s\n" "$host" "$username" "$credential" | git "credential-osxkeychain" store. Running these two commands on my Mac will make all the subsequent git commands that talk to Github use my custom token.

I run the same command on Travis CI, but it turns out Travis CI is not using my token(For example I tried to do a git clone for a repo that Travis does not have access to but my custom token has access to, Travis CI fails to clone the repo).

So now I am looking for a way to basically remove the existing GitHub Token(or other forms of credentials) and place my custom token in the build env to use.

Imprint