Skip to content

Instantly share code, notes, and snippets.

@joshbetz
Created May 9, 2017 21:04
Show Gist options
  • Save joshbetz/26903ccca8faa73abd0fb264845e0f49 to your computer and use it in GitHub Desktop.
Save joshbetz/26903ccca8faa73abd0fb264845e0f49 to your computer and use it in GitHub Desktop.
#!/bin/bash
client_id=$1
client_secret=$2
redirect_uri=$3
if [[ -z $client_id || -z $client_secret || -z $redirect_uri ]]; then
echo "Usage: $0 <client_id> <client_secret> <redirect_uri>"
exit 1
fi
open "https://public-api.wordpress.com/oauth2/authorize?client_id=$client_id&redirect_uri=$redirect_uri&response_type=code"
read -p "Enter the code: " code
echo
curl https://public-api.wordpress.com/oauth2/token -d "client_id=$client_id&client_secret=$client_secret&code=$code&redirect_uri=$redirect_uri&grant_type=authorization_code"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment