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 8134511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:03:40+00:00 2026-06-06T10:03:40+00:00

I am using the ClientLogin method and cURL to login to the google API’s.

  • 0

I am using the ClientLogin method and cURL to login to the google API’s. This works fine and I receive a Token for further usage. I can now query docs.google.com by using

        $curl = curl_init();

        $headers = array(
            "Authorization: GoogleLogin auth=" . $auth,
            "GData-Version: 3.0",
        );

        curl_setopt($curl, CURLOPT_URL, "https://docs.google.com/feeds/default/private/full");
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curl, CURLOPT_POST, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

        $response = curl_exec($curl);
        curl_close($curl);

This works fine and I get a list of all the documents available in my google docs account. But if I try the same query to spreadsheets.google.com with the URL obtained from the api documentation:

https://spreadsheets.google.com/feeds/spreadsheets/private/full

I get a 401 error saying that the token used is invalid. I am using the same token and query in both cases. Do I need a different token for the google spreadsheets api?

Edit:
This is how I request the Token:

        $clientlogin_url = "https://www.google.com/accounts/ClientLogin";
        $clientlogin_post = array(
            "accountType" => "HOSTED_OR_GOOGLE",
            "Email" => "my email",
            "Passwd" => "my password",
            "service" => "writely",
            "source" => "my application name"
        );

        $curl = curl_init($clientlogin_url);

        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $clientlogin_post);
        curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

        $response = curl_exec($curl);

        preg_match("/Auth=([a-z0-9_-]+)/i", $response, $matches);
        $auth = $matches[1];
        curl_close($curl);
  • 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-06-06T10:03:41+00:00Added an answer on June 6, 2026 at 10:03 am

    Short answer – Yes. You need to generate different tokens for different services. The service names you pass in to retrieve an auh token are different in each case. See here for more details – https://developers.google.com/gdata/faq

    For example from the docs the req for spreadsheets would be

    $clientlogin_post = array(
                "accountType" => "HOSTED_OR_GOOGLE",
                "Email" => "my email",
                "Passwd" => "my password",
                "service" => "wise",
                "source" => "my application name"
            );
    
    • 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 interface with the Google Reader (undocumented/unofficial) API using information from this
I'm using this jQuery AJAX call to google's ClientLogin. $.ajax({ url:https://www.google.com/accounts/ClientLogin, type:POST, data:{'Email': 'myusername',
i'm using a maven project with following dependency : <dependency> <groupId>com.google.api.client</groupId> <artifactId>google-api-client-googleapis-auth-clientlogin</artifactId> <version>1.2.3-alpha</version> </dependency>
I am trying to authenticate to a Google account using Google's ClientLogin method. I
I'm using the Zend_Gdata_Photos PHP client to access the Google Picasa API, trying to
I'm currently using this function to get all my contacts from Google Contacts. session_start();
I'm using the BLogger API (google) to try and search for certain strings (i.e.'John
I'm attempting to add a subscription to Google Reader, using it's API, however I'm
I am using FormsAuthentication.SetAuthCookie Method in my application.after Client login i am setting FormsAuthentication.SetAuthCookie(txtUserNo.Text.Trim(),

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.