You can also get the token by running the following script:
CLIENT_ID=YOUR-CLIENT-ID
CLIENT_SECRET=YOUR-CLIENT-SECRET
CODE=THE-CODE-ABOVE
URL="https://github.com/login/oauth/access_token"
curl -X POST $URL -H "Accept: application/json" -H 'Content-Type: application/x-www-form-urlencoded' -d "code=$CODE&client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET"