Programmatically getting access to a users Ad account through OAuth




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.



Hi @shahjahanw! Yes, it’s possible:
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, although it needs just a few tweaks to work with the Ads API.

Another library is, written by @hector_borras specifically for working with the Ads API, but one which I have not tested personally.


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.


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: