Need to authorized google adsense api using Curl

429 views
Skip to first unread message

Dinero spt

unread,
Oct 5, 2012, 7:09:32 AM10/5/12
to adsen...@googlegroups.com

Hi ,

I need to set a cron that can fetch the adsense domain report for my account .Please let me know if there is any way to get authorized using OAuth2 authorization using curl (not using the browser, as currently it is required for google adsense api ). I am using google-api-php-client for adsense report.

Thanks in advance.

Dinero spt

unread,
Oct 10, 2012, 2:20:07 AM10/10/12
to adsen...@googlegroups.com

 First of all , I am still looking for the way if i can get the domain report by google by setting a daily cron.

 But currently I am trying to get the custom channel report from google through the cron set for my application but when i run the file on browser it gives me following error .

 

HTTP method GET is not supported by this URL

Error 405


I am using PHP as scripting language.and have the adsense account and can check the report on adsense dashboard.

I just want to automate the process.

Any kind of help is appriciated.

Thanks in advance.

Netsphere Development

unread,
Oct 16, 2012, 8:47:42 AM10/16/12
to adsen...@googlegroups.com
Thanks Google team for response.

I have to access google adsense report via curl, so that each day my cron will run and save the report for my reporting system. And as cron dont runs on browser i need a way to do this without "having the approval_prompt" not even once.

for this i have one script that is working fine for my localhost but not on my live domain.

at live domain it gives error (screenshot attached).

Any help will be greatly appreciated.

Thanks ,

On Wed, Oct 10, 2012 at 4:05 PM, <adsen...@googlegroups.com> wrote:
Hi there,

You can definitely perform OAuth 2.0 authentication via simple HTTP requests with e.g. curl, but of course it would be much easier to use an OAuth 2.0 library :)

In any case, the OAuth 2.0 playground should be a huge help in showing you how to do OAuth directly: https://developers.google.com/oauthplayground/

Hope this helps!

Cheers,
Sérgio

---
Sérgio Gomes
Developer Relations

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London SW1W 9TQ
Registered in England Number: 3977902


Google Inc.| Developer Relations | AdSense API Team | developers.google.com/adsense

Follow us on our Google Ads Developer page on Google+ and our Google Ads Developer Blog to learn more about the different Ads APIs at Google.


--
You received this message because you are subscribed to the Google Groups "AdSense API Forum" group.
To view this discussion on the web visit https://groups.google.com/d/msg/adsense-api/-/br8qZoBRUMYJ.
To post to this group, send email to adsen...@googlegroups.com.
To unsubscribe from this group, send email to adsense-api+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/adsense-api?hl=en.

google_error.jpg

Sérgio Gomes (AdSense API Team)

unread,
Oct 18, 2012, 12:35:08 PM10/18/12
to adsen...@googlegroups.com
Hello again,

The error you're getting seems to be a standard Google account login security measure. If you fill that in once, it should clear.

As for getting the approval prompt, I'm assuming you can run your application once, manually, before turning it into a cron job. If you do that and complete the flow, you'll get an access token and a refresh token. The former is used to make requests, but is short-lived, whereas the latter allows you to generate new access tokens but does not expire (unless the user explicitly revokes access to your application).

Once you have the refresh token, your application can generate new access tokens as needed, automatically, without any user input, which should solve your problem and keep it fully automated.

Hope this helps!

Cheers,
Sérgio

---
Sérgio Gomes
Developer Relations

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London SW1W 9TQ
Registered in England Number: 3977902

Google Inc.| Developer Relations | AdSense API Team | developers.google.com/adsense

Follow us on our Google Ads Developer page on Google+ and our Google Ads Developer Blog to learn more about the different Ads APIs at Google.


Reply all
Reply to author
Forward
0 new messages