Guides for using OAuth to make API calls?

I'm having trouble figuring out how to use the credentials (client ID, client secret, auth link, token) a website has provided to make calls to its API to get data from it.

Does anyone have a guide they found particularly easy to follow they could share, or github repos that tackle the issue (n.b. make sure you gitignore'd your creds!!)? The documentation I've seen talks about creating a whole flask app to deal with it and I really hope there's a simpler way of just passing those things to some request object.

But maybe that is the only way. Any help would be greatly appreciated!

Posted Aug 15, 2018, 2:19 PM UTC

55
officialgeleagleEggs•

Typically you can store it in a config file locally (AWS), or specify it directly in the console (Twitter). What service is it?

2
bbqbotOP•

AdRoll; they have marketing data I'm trying to pull.

1
officialgeleagleEggs•

At first glance, it's a single call:

adroll_auth = ('[email protected]', 'great-password')
r = requests.get(
    'https://services.adroll.com/api/v1/organization/get_advertisables?apikey=MYAPIKEY',
auth=adroll_auth
)

Are you trying to do something beyond that?

0
bbqbotOP•

I tried that and only get <Response [200]> as a result. They also said they've deprecated http basic access auth in lieu of OAuth 2.0 which I have no experience in.

I'm trying to get marketing campaign data, but at this point I'll take any successful API beyond the above as progress.

1
officialgeleagleEggs•

For starters, pip install flask and run this demo from python: https://requests-oauthlib.readthedocs.io/en/latest/examples/real_world_example.html

I would take the basic route (Don't worry that you don't know flask). Install the library and run that module (After changing it for AdRoll).

The details for changing for AdRoll can be picked out of https://developers.adroll.com/docs/guides/oauth.html

1