Skip to content

Instantly share code, notes, and snippets.

@dmtrs
Created January 31, 2017 13:50
Show Gist options
  • Save dmtrs/4baaa8b9932b5fe121b3cbff0202f351 to your computer and use it in GitHub Desktop.
Save dmtrs/4baaa8b9932b5fe121b3cbff0202f351 to your computer and use it in GitHub Desktop.
Avocarrot new authentication service test
#!/bin/bash
# Requirements:
# - curl
# - jq
CLIENT_ID=your-client-id
CLIENT_SECRET=your-client-secret
USERNAME=publisher-username
PASSWORD=publisher-password
curl https://auth.avocarrot.com/token \
-X POST \
-d "client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&grant_type=password&username=$USERNAME&password=$PASSWORD" \
-H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' > /tmp/access_token.json
cat /tmp/access_token.json
REFRESH_TOKEN=$(cat /tmp/access_token.json | jq -r '.refresh_token')
curl https://auth.avocarrot.com/token \
-X POST \
-d "client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&grant_type=refresh_token&refresh_token=$REFRESH_TOKEN" \
-H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' > /tmp/refresh_token.json
ACCESS_TOKEN=$(cat /tmp/refresh_token.json | jq -r '.access_token')
curl https://auth.avocarrot.com/users/me -H "Authorization: Bearer $ACCESS_TOKEN" | jq '.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment