Sam Lee
Sam Lee

Reputation: 10463

Accessing AdSense API from a ruby script

I'm trying to run a ruby script that does some analysis via the AdSense API. It seems like the AdSense API is written in the context of a web app and then a user that logs in. My use case is different; I want to run a script against my own AdSense account.

Is this possible? Or do I need to set up a web site flow to get an access token?

Upvotes: 0

Views: 93

Answers (1)

Dean Lukies
Dean Lukies

Reputation: 109

if you want to run e.g. a nightly script against your Adsense account to generate a report you need to:

  • do the auth flow once
  • request and store a refresh token
  • use that refresh token to authorize your report going forward.

For an example, if you take a look at https://github.com/googleads/googleads-adsense-examples/blob/master/ruby/v1.x/adsense_common.rb and look at CREDENTIAL_STORE_FILE ... that is the name of the file with the token in it and you can see the auth options starting around line 50

thanks,

Dean

Upvotes: 0

Related Questions