Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6997475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:17:17+00:00 2026-05-27T20:17:17+00:00

I am trying to: Login to Google Download CSV data from Google Trends I

  • 0

I am trying to:

  1. Login to Google
  2. Download CSV data from Google Trends

I am succeeding in (1) but not in (2). I get returned an authorization-token from Google, and am sending it with the subsequent request to Trends, but nevertheless Google then returns an error: “You must be signed in to export data from Google Trends”:

// http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html
$data = array(
  'accountType' => 'GOOGLE',
  'Email'       => 'my.email@gmail.com',
  'Passwd'      => 'my.password',
  'service'     => 'trendspro',
  'source'      => 'company-application-1.0'
);

$ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, "https://www.google.com/accounts/ClientLogin");
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  curl_setopt($ch, CURLOPT_HTTPAUTH, false);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $response = curl_exec($ch);

  preg_match("/Auth=([a-z0-9_\-]+)/i", $response, $matches);

  // We now have an authorization-token
  $headers = array(
    "Authorization: GoogleLogin auth=" . $matches[1],
    "GData-Version: 3.0"
  );

  curl_setopt($ch, CURLOPT_URL, "http://www.google.com/trends/viz?q=MSFT&date=2011-2&geo=all&graph=all_csv&sort=0&sa=N");
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  curl_setopt($ch, CURLOPT_HEADER, false);
  curl_setopt($ch, CURLOPT_POST, false);
  $csv = curl_exec($ch);
curl_close($ch);

// Returns : "You must be signed in to export data from Google Trends"
// Expected: CSV data stream
print_r($csv);

For some reason, the auth-tokens I am sending to Google Trends, is not being accepted or ignored. I don’t know exactly what happens, since no additional error-information is given.

Does anyone see what I am doing wrong? If you can get it to work, meaning that Google is returning the CSV data, then the bounty is yours and we both have a late Christmas present 🙂


So I figured out the problem has nothing to do with cURL. What I did was:

  • Go to https://www.google.com/accounts/ClientLogin?accountType=GOOGLE&Email=my.email@gmail.com&Passwd=my.password&service=trendspro&source=ding-dang-1. The return is:
SID=DQAAAMUAAADMqt...aYPaYniC_iW
LSID=DQAAAMcAAACI5...YDTBDt_xZC9
Auth=DQAAAMgAAABm8...trXgqNv-g0H
  • I copy the returned Auth token: DQAAAMgAAABm8…trXgqNv-g0H
  • I send a GET request using the POSTman Chrome extension to http://www.google.com/trends/viz?q=MSFT&date=2011-2&geo=all&graph=all_csv&sort=0&sa=N using the header:
GData-Version: 3.0     
Authorization: GoogleLogin auth=DQAAAMgAAABm8...trXgqNv-g0H
  • I get returned:

headers:

Date: Tue, 27 Dec 2011 00:17:20 GMT
Content-Encoding: gzip
Content-Disposition: filename=trends.csv
Content-Length: 97
X-XSS-Protection: 1; mode=block
Server: Google Trends
X-Frame-Options: SAMEORIGIN
Content-Type: text/csv; charset=UTF-8
Cache-Control: private

data:

You must be signed in to export data from Google Trends

In other words, I’m sending headers as defined by Google on http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html but no luck getting a proper return. An there is about * no * info on the Interwebs concerning this. Who knows what the problem is here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:17:18+00:00Added an answer on May 27, 2026 at 8:17 pm

    After checking your code, the problem is that Google Trends needs the SID key and not Auth. Here’s the code I wrote to download the csv’s

    <?php
    
    header('content-type: text/plain');
    
    // Set account login info
    $data['post'] = array(
      'accountType' => 'HOSTED_OR_GOOGLE',  // indicates a Google account
      'Email'       => '',  // full email address
      'Passwd'      => '',
      'service'     => 'trendspro', // Name of the Google service
      'source'      => 'codecri.me-example-1.0' // Application's name, e.g. companyName-applicationName-versionID
    );
    
    $response = xhttp::fetch('https://www.google.com/accounts/ClientLogin', $data);
    
    // Test if unsuccessful
    if(!$response['successful']) {
        echo 'response: '; print_r($response);
        die();
    }
    
    // Extract SID
    preg_match('/SID=(.+)/', $response['body'], $matches);
    $sid = $matches[1];
    
    // Erase POST variables used on the previous xhttp call
    $data = array();
    
    // Set the SID in cookies
    $data['cookies'] = array(
        'SID' => $sid
    );
    

    This uses my xhttp class, a cURL wrapper.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im trying to figure out how to get the Token from Google using client-login
I'm trying to integrate the Google Federated Login with a premier apps account, but
I'm trying to get a session token to use the Google Calendar API using
I'm trying to mimic the login page from the example http://tipfy-auth.appspot.com (source http://code.google.com/p/tipfy/source/browse/examples/auth/app/ )
I'm trying to do a simple static login with google app engine and android
I am trying to use django-social-auth to implement google openid login into my app,
I'm trying to create an application that uses Google OAuth for login, and then
I'm trying to login with the following controller action, but my login attempt keeps
I am trying to access google calendar from php program. I am using a
So I'm trying to embed the google analytics login page onto a page. Works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.