Google Product Forums

Re: Server-side PHP script?

Patrick NI Dec 27, 2011 12:23 AM
Posted in group: Google Affiliate Network

Categories: API Questions :

Esnagle, 
You just authorised your APP only once, and kept your client id, client secret, and refresh token in file.
When you try to get yesterday's activity, you need to get the "access token" via "refresh token" first, like below,
curl -c g.c -b g.c -d "client_id=&client_secret=&refresh_token=&grant_type=refresh_token" https://accounts.google.com/o/oauth2/token

The response below,
{

  "access_token":"1/fFBGRNJru1FQd44AzqT3Zg",
  "expires_in":3920,
  "token_type":"Bearer"
}

Then you can use the new access token to get the data, like below
curl -H "Authorization: Bearer 1/fFBGRNJru1FQd44AzqT3Zg" -c g.c -b g.c https://www.googleapis.com/gan/v1beta1/publishers/publisher_id/events

Because you are the only one of your APP, you will never revoke the authorization of your APP.