Developers Diary

Google Analytics API: unknown redirect URL

Some success! I now figured out  the openauth 2.0 working with the Google Analtyics API.  I spent some time trying to figure out why I had error message “unknown redirect URL”.  After finally finding the GOOGLE API PHP CLIENT library, I looked under EXAMPLES and there is all the connection code you need for any google offering.  It still took me a *few* minutes to figure out the file structure. After reading the //comments in the example file, I learned what the error meant. The redirect URL has to be the second index file it hits.  That means the first index page you encounter (this one was named simple.php) you give all the proper API credentials, and then you click the “connect me” link.  That link takes you to the inside folder (the demo folder containing all the sample code) which has it’s OWN index page.  It’s that index page that is the redirect URL.

Google Analtyics API redirect URL helpSounds really simple right now, but hindsight is 20/20.

 

fileoutsidethefolder.php  (the credentials to get in)

Folder:

  • authHelpher.php
  • coreReportingApireference.php
  • error)log
  • helloAnaltyicsApi.php
  • index.php (once you login, redirect to this file inside the folder)
  • managementAPIReference.php
  • storage.php