I have PHP code to achieve it. This is not to say that this is impossible. I used this method for Google Analytics, Adwords, Google+ and YouTube. He worked with all the services mentioned.
Trick should use the state parameter, which will be used as a dynamic URL. Hope this helps everyone.
// Auth URL // $campaign_id will be different for everyone $dynamic_redirect = 'http://' . $_SERVER['HTTP_HOST'] . "/analytics/$campaign_id"; $client_id = 'XXXXXXXX'; $redirect_uri = 'API_REDIRECT_URI'; // Fixed URL, it will not be changed $auth_url = "https://accounts.google.com/AccountChooser?service=lso&continue="; $auth_url .= urlencode("https://accounts.google.com/o/oauth2/auth?response_type=code&scope=https://www.googleapis.com/auth/analytics.readonly&access_type=offline&redirect_uri=$redirect_uri&approval_prompt=force&state=$dynamic_redirect&client_id=$client_id"); /*************************************/ API_REDIRECT_URI PAGE /*************************************/ $redirect_url = $_GET['state'];
source share