What does a request for an ads api call look like, and what are the steps for getting the headers?

oauth
ads
api

#1

I followed the steps for creating a bearer token for application-only authentication, and was able to successfully grab data from the newsfeed REST endpoint

However, using the same headers to GET https://ads-api.twitter.com/1/accounts results in

{
	"errors": [
		{
			"code": "UNAUTHORIZED_ACCESS",
			"message": "This request is not properly authenticated"
		}
	],
	"request": {
		"params": {}
	}
}

Sample code in https://github.com/twitterdev/twitter-python-ads-sdk seems to imply that ACCESS_TOKEN and ACCESS_TOKEN_SECRET are also required. How to throw those into the mix?

What are all the headers required? What would a successful curl command look like, and what are the steps to get each one?

I’ve been digging through google and the docs site for hours, guidance would be so incredibly appreciated


#2

Hey,

Sorry that it has been hard to find this information - the best way to inspect headers and learn how we expect them to be sent is to check the raw headers that “twurl” tool uses (which is literally just a wrapper on top of curl).

Typing twurl -T will print out help instructions, and including a lowercase -t is what prints out headers…but there is another old video containing an intro to twurl and we continue to expand these video tutorials so look out for that:

I would also ask for feedback of why you think you can’t use one of the SDKs available and what sort of features or language you are looking for.

Thanks,

John


#3

Thank you so much for the fast response, video and the tip with twurl!

I’m trying to integrate twitter analytics into a node application and I couldn’t find a node library that would work with ads-api. I’d be happy enough to make commandline calls to twurl from node though

I'm actually having some trouble getting twurl successfully working as well, After successfully authorizing via `twurl authorize --consumer-key XXXXX --consumer-secret XXXXX` and receiving `Authorization successful` after inputting the pin, The command `twurl -H "ads-api.twitter.com" "/1/accounts"` fails with `{"errors":[{"code":"UNAUTHORIZED_CLIENT_APPLICATION","message":"The client application making this request does not have access to this API"}],"request":{"params":{}}}` Has the authorization procedure changed with v1 of the api as well?

Edit: Oops, I just realized I skipped over the section about having to apply for access to the api


#4

Thanks for updating your most recent post, @CheapSteak.