Google Drive SDK

About: get

Requires authorization

Gets the information about the current user along with Drive API settings Try it now or see an example.

Request

HTTP request

GET https://www.googleapis.com/drive/v2/about

Parameters

Parameter name Value Description
Optional query parameters
includeSubscribed boolean When calculating the number of remaining change IDs, whether to include shared files and public files the user has opened. When set to false, this counts only change IDs for owned files and any shared or public files that the user has explictly added to a folder in Drive. (Default: true)
maxChangeIdCount long Maximum number of remaining change IDs to count
startChangeId long Change ID to start counting from when calculating number of remaining change IDs

Authorization

This request requires authorization with at least one of the following scopes (read more about authentication and authorization).

Scope
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive.metadata.readonly
https://www.googleapis.com/auth/drive.appdata

Request body

Do not supply a request body with this method.

Response

If successful, this method returns an About resource in the response body.

Examples

Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).

Java

Uses the Java client library

import com.google.api.services.drive.Drive;
import com.google.api.services.drive.model.About;

import java.io.IOException;
// ...

public class MyClass {

  // ...

  /**
   * Print information about the current user along with the Drive API
   * settings.
   *
   * @param service Drive API service instance.
   */
  private static void printAbout(Drive service) {
    try {
      About about = service.about().get().execute();

      System.out.println("Current user name: " + about.getName());
      System.out.println("Root folder ID: " + about.getRootFolderId());
      System.out.println("Total quota (bytes): " + about.getQuotaBytesTotal());
      System.out.println("Used quota (bytes): " + about.getQuotaBytesUsed());
    } catch (IOException e) {
      System.out.println("An error occurred: " + e);
    }
  }

  // ...
}

.NET

Uses the .NET client library

using Google.Apis.Drive.v2;
using Google.Apis.Drive.v2.Data;

using System.Net;
// ...

public class MyClass {

  // ...

  /// <summary>
  /// Print information about the current user along with the Drive API
  /// settings.
  /// </summary>
  /// <param name="service">Drive API service instance.</param>
  public static void PrintAbout(DriveService service) {
    try {
      About about = service.About.Get().Fetch();

      Console.WriteLine("Current user name: " + about.Name);
      Console.WriteLine("Root folder ID: " + about.RootFolderId);
      Console.WriteLine("Total quota (bytes): " + about.QuotaBytesTotal);
      Console.WriteLine("Used quota (bytes): " + about.QuotaBytesUsed);
    } catch (Exception e) {
      Console.WriteLine("An error occurred: " + e.Message);
    }
  }

  // ...
}

PHP

Uses the PHP client library

/**
 * Print information about the current user along with the Drive API settings.
 *
 * @param Google_DriveService $service Drive API service instance.
 */
function printAbout($service) {
  try {
    $about = $service->about->get();

    print "Current user name: " . $about->getName();
    print "Root folder ID: " . $about->getRootFolderId();
    print "Total quota (bytes): " . $about->getQuotaBytesTotal();
    print "Used quota (bytes): " . $about->getQuotaBytesUsed();
  } catch (Exception $e) {
    print "An error occurred: " . $e->getMessage();
  }
}

Python

Uses the Python client library

from apiclient import errors
# ...

def print_about(service):
  """Print information about the user along with the Drive API settings.

  Args:
    service: Drive API service instance.
  """
  try:
    about = service.about().get().execute()

    print 'Current user name: %s' % about['name']
    print 'Root folder ID: %s' % about['rootFolderId']
    print 'Total quota (bytes): %s' % about['quotaBytesTotal']
    print 'Used quota (bytes): %s' % about['quotaBytesUsed']
  except errors.HttpError, error:
    print 'An error occurred: %s' % error

Ruby

Uses the Ruby client library

##
# Print information about the user along with the Drive API settings
#
# @param [Google::APIClient] client
#   Authorized client instance
# @return nil
def print_about(client)
  drive = client.discovered_api('drive', 'v2')
  result = client.execute(
    :api_method => drive.about.get)
  if result.status == 200
    about = result.data
    puts "Current user name: #{about.name}"
    puts "Root folder ID: #{about.root_folder_id}"
    puts "Total quota (bytes): #{about.quota_bytes_total}"
    puts "Used quota (bytes): #{about.quota_bytes_used}"
  else
    puts "An error occurred: #{result.data['error']['message']}"
  end
end

JavaScript

Uses the JavaScript client library

/**
 * Print information about the current user along with the Drive API
 * settings.
 */
function printAbout() {
  var request = gapi.client.drive.about.get();
  request.execute(function(resp) {
    console.log('Current user name: ' + resp.name);
    console.log('Root folder ID: ' + resp.rootFolderId);
    console.log('Total quota (bytes): ' + resp.quotaBytesTotal);
    console.log('Used quota (bytes): ' + resp.quotaBytesUsed);
  });
}

Go

Uses the Go client library

import (
  "code.google.com/p/google-api-go-client/drive/v2"
  "fmt"
)

// PrintAbout prints information from the user's Drive account
func PrintAbout(d *drive.Service) error {
  a, err := d.About.Get().Do()
  if err != nil {
    fmt.Printf("An error occurred: %v\n", err)
    return err
  }
  fmt.Printf("About: %v\n", a)
  fmt.Printf("Current user name: %v\n", a.Name)
  fmt.Printf("Root folder ID: %v\n", a.RootFolderId)
  fmt.Printf("Total quota (bytes): %v\n", a.QuotaBytesTotal)
  fmt.Printf("Used quota (bytes): %v\n", a.QuotaBytesUsed)
  return nil
}

Objective-C

Uses the Objective-C client library

#import "GTLDrive.h"
// ...

+ (void)printAboutWithService:(GTLServiceDrive *)service {
  GTLQueryDrive *query = [GTLQueryDrive queryForAboutGet];
  // queryTicket can be used to track the status of the request.
  GTLServiceTicket *queryTicket =
    [service executeQuery:query
        completionHandler:^(GTLServiceTicket *ticket, GTLDriveAbout *about,
                            NSError *error) {
          if (error == nil) {
            NSLog(@"Current user name: %@", about.name);
            NSLog(@"Root folder ID: %@", about.rootFolderId);
            NSLog(@"Total quota (bytes): %@", about.quotaBytesTotal);
            NSLog(@"Used quota (bytes): %@", about.quotaBytesUsed);
          } else {
            NSLog(@"An error occurred: %@", error);
          }
        }];
}

// ...

Try it!

Use the APIs Explorer below to call this method on live data and see the response.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.