Skip to content

Instantly share code, notes, and snippets.

@btoews
Created August 14, 2015 18:43
Show Gist options
  • Save btoews/b07c3e6a2a9d9b795848 to your computer and use it in GitHub Desktop.
Save btoews/b07c3e6a2a9d9b795848 to your computer and use it in GitHub Desktop.
Store GitHub access token in keychain
#!/bin/bash
echo -n "GitHub username: "
read username
echo -n "GitHub personal access token: "
read token
echo "Storing GitHub access token in keychain."
security add-generic-password -s github_access_token -a $username -w $token
echo "Configuring your .profile to get your access token from the keychain and put it in the \$GITHUB_ACCESS_TOKEN variable"
echo "export GITHUB_ACCESS_TOKEN=\$(security find-generic-password -s github_access_token -a $username -w)" >> ~/.profile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment