I’ve seen many people asking about OAuth and Twurl. I’ve written a small primer for my organization and will share it here:
Twurl is twitter’s curl client. The advantage of using it is that we can pass urls around without OAuth signatures. OAuth is stored in the .twurlrc.
To generate the OAuth signatures:
- Log in to your twitter account and find the “Keys and Access Tokens” of your app
- Use twurl with the following commands:
account authentication:
twurl authorize --consumer-key {API-KEY} --consumer-secret {API-SECRET}
user authentication:
twurl authorize -u {USERNAME} -p {PASSWORD} --consumer-key {API-KEY} --consumer-secret {API-SECRET}
With account authentication, the user account is implied by the API credentials. If you are looking to authenticate against a separate account, use user authentication.
You can access the Ads API with such a call:
twurl -t -H ads-api.twitter.com /0/accounts | python -m json.tool
If you did both authentications above (well, not with my account) then issue this command:
twurl accounts
which will give you:
{USERNAME}
{KEY} (default)
{USERNAME}
{KEY}
You can change accounts with:
twurl set default {USERNAME}
or:
twurl set default {USERNAME} {KEY}
the latter is if you are using multiple keys.
You can probably get most of the above info with:
twurl --tutorial