Programmatically getting access to a users Ad account through OAuth

oauth
ads
account-access
api

#1

Hi,

We are an ad agency looking to promote Twitter campaigns for our clients through the Ads Api.

We would like to get access to our clients Ad account programmatically by asking them to allow us permission through the OAuth sign in flow. Is this possible?

So far the clients have to open up their Ad account and give us permission from within Twitter UI. We would like to take that step out of the process for the convenience of the user.

Thanks.


#2

Hi @shahjahanw! Yes, it’s possible: https://dev.twitter.com/oauth/3-legged
I suggest you use a 3rd party library for this, to not go through the hassle of generating the Authorization request header.

I am using https://github.com/abraham/twitteroauth, although it needs just a few tweaks to work with the Ads API.

Another library is https://github.com/hborras/twitter-php-ads-sdk, written by @hector_borras specifically for working with the Ads API, but one which I have not tested personally.


#3

I agree, a 3rd party is the way to go. I coudn’t make any progress with getting any AuthTokens until I used Auth0 to handle it, which worked like a charm for my Rails app. Although, it may not be useful if you have a large number of users.


#4

Hi @majoritasdev. Thanks for the solution. I was indeed following the same methodology but my access secret for the APP had not been reset. Permissions are functional and flowing :slight_smile: