### Setup and Make Request (PHP) Source: https://developers.google.com/ad-manager/api Demonstrates setting up the PHP client library, including installing dependencies, configuring credentials via adsapi_php.ini, and making a request to get the current network information. This code must be run from the command line. ```bash composer require googleads/googleads-php-lib curl https://raw.githubusercontent.com/googleads/googleads-php-lib/main/examples/AdManager/adsapi_php.ini -o ~/adsapi_php.ini ``` ```ini [AD_MANAGER] networkCode = "INSERT_NETWORK_CODE_HERE" applicationName = "INSERT_APPLICATION_NAME_HERE" [OAUTH2] jsonKeyFilePath = "INSERT_ABSOLUTE_PATH_TO_OAUTH2_JSON_KEY_FILE_HERE" scopes = "https://www.googleapis.com/auth/dfp" ``` ```php fromFile() ->build(); // Construct an API session configured from a properties file and the OAuth2 // credentials above. $session = (new AdManagerSessionBuilder()) ->fromFile() ->withOAuth2Credential($oAuth2Credential) ->build(); // Get a service. $serviceFactory = new ServiceFactory(); $networkService = $serviceFactory->createNetworkService($session); // Make a request $network = $networkService->getCurrentNetwork(); printf( "Network with code %d and display name '%s' was found.\n", $network->getNetworkCode(), $network->getDisplayName() ); ``` -------------------------------- ### Run PHP Built-in Web Server for Examples Source: https://developers.google.com/api-client-library/php Start the PHP built-in web server to view the client library examples in your browser. ```bash $ php -S localhost:8000 -t examples/ ``` -------------------------------- ### Clone and Run 3D Simple Marker Sample Source: https://developers.google.com/maps/documentation/javascript/examples/3d/marker Use these commands to clone the sample repository, install dependencies, and start the application. Ensure Git and Node.js are installed locally. ```bash git clone https://github.com/googlemaps-samples/js-api-samples.git cd samples/3d-simple-marker npm i npm start ``` -------------------------------- ### Ruby Client Library Setup (Install) Source: https://developers.google.com/ad-manager/api/beta Install the google-ads-ad_manager gem after adding it to your Gemfile. ```APIDOC ## Ruby Client Library Setup (Install) ### Description Install the google-ads-ad_manager gem after adding it to your Gemfile. ### Code ```bash gem install google-ads_ad_manager ``` ``` -------------------------------- ### Run Node.js OAuth 2.0 Example Source: https://developers.google.com/accounts/docs/OAuth2WebServer Executes the Node.js OAuth 2.0 example using the installed Google API Client Library. Ensure Node.js is installed and the `main.js` file is created. ```bash node .\main.js ``` -------------------------------- ### Setup Google Drive Folder and Trigger Source: https://developers.google.com/apps-script/samples/automations/upload-files Runs the setup process, creating a Google Drive folder for uploads and installing an onFormSubmit trigger. Ensure this function is run before using the sample. ```javascript // TODO You must run the setUp() function before you start using this sample. /** * The setUp() function performs the following: * - Creates a Google Drive folder named by the APP_FOLDER_NAME * variable in the Code.gs file. * - Creates a trigger to handle onFormSubmit events. */ function setUp() { // Ensures the root destination folder exists. const appFolder = getFolder_(APP_FOLDER_NAME); if (appFolder !== null) { console.log(`Application folder setup. Name: ${appFolder.getName()} ID: ${appFolder.getId()} URL: ${appFolder.getUrl()}`); } else { console.log("Could not setup application folder."); } // Calls the function that creates the Forms onSubmit trigger. installTrigger_(); } /** * Returns a folder to store uploaded files in the same location * in Drive where the form is located. First, it checks if the folder * already exists, and creates it if it doesn't. * * @param {string} folderName - Name of the Drive folder. * @return {object} Google Drive Folder */ function getFolder_(folderName) { // Gets the Drive folder where the form is located. const ssId = FormApp.getActiveForm().getId(); const parentFolder = DriveApp.getFileById(ssId).getParents().next(); // Iterates through the subfolders to check if folder already exists. // The script checks for the folder name specified in the APP_FOLDER_NAME variable. const subFolders = parentFolder.getFolders(); while (subFolders.hasNext()) { const folder = subFolders.next(); // Returns the existing folder if found. if (folder.getName() === folderName) { return folder; } } // Creates a new folder if one doesn't already exist. return parentFolder .createFolder(folderName) .setDescription( `Created by ${APP_TITLE} application to store uploaded files.`, ); } /** * Installs trigger to capture onFormSubmit event when a form is submitted. * Ensures that the trigger is only installed once. * Called by setup(). */ function installTrigger_() { // Ensures existing trigger doesn't already exist. const propTriggerId = PropertiesService.getScriptProperties().getProperty("triggerUniqueId"); if (propTriggerId !== null) { const triggers = ScriptApp.getProjectTriggers(); for (const t in triggers) { if (triggers[t].getUniqueId() === propTriggerId) { console.log( `Trigger with the following unique ID already exists: ${propTriggerId}`, ); return; } } } // Creates the trigger if one doesn't exist. const triggerUniqueId = ScriptApp.newTrigger("onFormSubmit") .forForm(FormApp.getActiveForm()) .onFormSubmit() .create() .getUniqueId(); PropertiesService.getScriptProperties().setProperty( "triggerUniqueId", triggerUniqueId, ); console.log( `Trigger with the following unique ID was created: ${triggerUniqueId}`, ); } /** * Removes all script properties and triggers for the project. * Use primarily to test setup routines. */ function removeTriggersAndScriptProperties() { PropertiesService.getScriptProperties().deleteAllProperties(); // Removes all triggers associated with project. const triggers = ScriptApp.getProjectTriggers(); for (const t in triggers) { ScriptApp.deleteTrigger(triggers[t]); } } /** * Removes all form responses to reset the form. */ function deleteAllResponses() { FormApp.getActiveForm().deleteAllResponses(); } ``` -------------------------------- ### PHP Client Library Setup Source: https://developers.google.com/ad-manager/api/beta Install the Ad Manager client library using Composer. ```APIDOC ## PHP Client Library Setup ### Description Install the Ad Manager client library using Composer. ### Code ```bash composer require googleads/ad-manager ``` ``` -------------------------------- ### Setup with Sample Documents Source: https://developers.google.com/apps-script/samples/automations/aggregate-document-content Initiates the setup process for demonstration purposes by calling the `setupConfig` function with the `true` argument. This is typically triggered from a custom menu item. ```javascript function setupWithSamples() { setupConfig(true); } ``` -------------------------------- ### List invoices for a billing setup using curl Source: https://developers.google.com/google-ads/api/docs/billing/invoice This example demonstrates how to get invoices for a given billing setup using a curl command. Ensure all required variables like API_VERSION, CUSTOMER_ID, DEVELOPER_TOKEN, MANAGER_CUSTOMER_ID, OAUTH2_ACCESS_TOKEN, BILLING_SETUP_ID, ISSUE_MONTH, and ISSUE_YEAR are set. ```Shell curl -f "https://googleads.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/invoices?billingSetup=${BILLING_SETUP_ID}&issueMonth=${ISSUE_MONTH}&issueYear=${ISSUE_YEAR}" \ --header "Content-Type: application/json" \ --header "developer-token: ${DEVELOPER_TOKEN}" \ --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \ --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" ``` -------------------------------- ### Get Clicks Metrics from Hotel Performance View Source: https://developers.google.com/google-ads/api/docs/hotel-ads/reporting Retrieve the total number of clicks from the hotel performance view. This query is a basic example for starting with Hotel Ads reporting. ```sql SELECT metrics.clicks FROM hotel_performance_view ``` ```json { "results": [ { "metrics": { "clicks": "78090" }, "hotelPerformanceView": { "resourceName": "customers/1234567890/hotelPerformanceView" } } ], "totalResultsCount": "1", "fieldMask": "metrics.clicks" } ``` -------------------------------- ### Get Network Information (.NET) Source: https://developers.google.com/ad-manager/api/beta Retrieve network details using the Ad Manager API client library for .NET. This example shows the basic setup for making the request. ```csharp using Google.Ads.AdManager.V1; public sealed partial class GeneratedNetworkServiceClientSnippets { public void GetNetwork() { // Create client NetworkServiceClient networkServiceClient = NetworkServiceClient.Create(); // Initialize request argument(s) string name = "networks/NETWORK_CODE"; // Make the request Network response = networkServiceClient.GetNetwork(name); } } ``` -------------------------------- ### Clone Sample Instructions Source: https://developers.google.com/maps/documentation/javascript/examples/3d/camera-restrictions Provides command-line instructions to clone the sample repository, navigate to the specific sample directory, install dependencies, and start the application. This is for running the sample locally. ```bash git clone https://github.com/googlemaps-samples/js-api-samples.git cd samples/3d-camera-boundary npm i npm start ``` -------------------------------- ### Get Blog Example Source: https://developers.google.com/blogger/docs/3.0/getting_started Example of how to get the posts on a specific blog, identified by its blog ID. ```APIDOC ## Get Blog ### Description Gets a specific blog, identified by its blog ID. ### Method GET ### Endpoint https://www.googleapis.com/blogger/v3/blogs/{blogId} ### Parameters #### Path Parameters - **blogId** (string) - Required - The ID of the blog to retrieve. #### Query Parameters - **key** (string) - Required - Your API key. ### Request Example ``` GET https://www.googleapis.com/blogger/v3/blogs/**3213900**?key=YOUR-API-KEY ``` ``` -------------------------------- ### Install npm dependencies Source: https://developers.google.com/codelabs/maps-platform/maps-platform-101-react-js Navigate to the \/starter directory and run npm install to install all the necessary dependencies listed in the package.json file. ```bash cd starter && npm install ``` -------------------------------- ### Example Setup and Execution Source: https://developers.google.com/google-ads/api/docs/display-upload-ads/create-display-upload-ad This section shows how to initialize the Google Ads API client and set up command-line options for customer ID and ad group ID. It ensures the example runs only when executed directly and not when included as a module. ```perl # Don't run the example if the file is being included. if (abs_path($0) ne abs_path(__FILE__)) { return 1; } # Get Google Ads Client, credentials will be read from ~/googleads.properties. my $api_client = Google::Ads::GoogleAds::Client->new(); # By default examples are set to die on any server returned fault. $api_client->set_die_on_faults(1); # Parameters passed on the command line will override any parameters set in code. GetOptions( "customer_id=s" => \$customer_id, "ad_group_id=i" => \$ad_group_id, ); ``` -------------------------------- ### Create an anchored adaptive banner view Source: https://developers.google.com/admob/unity/banner/anchored-adaptive This code creates an anchored adaptive banner view positioned to the bottom of the screen. Replace ANCHORED_ADAPTIVE_AD_UNIT_ID with your ad unit ID. After creation, load the banner as described in the Get Started guide. ```csharp // Get the device safe width in density-independent pixels. int deviceWidth = MobileAds.Utils.GetDeviceSafeWidth(); // Define the anchored adaptive ad size. AdSize adaptiveSize = AdSize.GetCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(deviceWidth); // Create an anchored adaptive banner view. bannerView = new BannerView("ANCHORED_ADAPTIVE_AD_UNIT_ID", adaptiveSize, AdPosition.Bottom); ``` -------------------------------- ### Get Account Hierarchy Ruby Example Source: https://developers.google.com/google-ads/api/docs/account-management/get-account-hierarchy This script retrieves the account hierarchy starting from a specified manager customer ID or all accessible customer IDs if no manager ID is provided. It uses a breadth-first search to build the hierarchy and then prints it recursively. ```ruby require 'optparse' require 'google/ads/google_ads' require 'thread' def get_account_hierarchy(manager_customer_id, login_customer_id) # GoogleAdsClient will read a config file from # ENV['HOME']/google_ads_config.rb when called without parameters client = Google::Ads::GoogleAds::GoogleAdsClient.new # Set the specified login customer ID. client.configure do |config| if login_customer_id config.login_customer_id = login_customer_id.to_i elsif manager_customer_id config.login_customer_id = manager_customer_id.to_i end end google_ads_service = client.service.google_ads seed_customer_ids = [] if manager_customer_id seed_customer_ids << manager_customer_id else puts 'No manager customer ID is specified. The example will print the ' 'hierarchies of all accessible customer IDs:' customer_resource_names = client.service.customer. list_accessible_customers().resource_names customer_resource_names.each do |res| seed_customer_ids << res.split('/')[1] end end search_query = <<~QUERY SELECT customer_client.client_customer, customer_client.level, customer_client.manager, customer_client.descriptive_name, customer_client.currency_code, customer_client.time_zone, customer_client.id FROM customer_client WHERE customer_client.level <= 1 QUERY seed_customer_ids.each do |seed_cid| # Performs a breadth-first search to build a dictionary that maps managers # to their child accounts (cid_to_children). unprocessed_customer_ids = Queue.new unprocessed_customer_ids << seed_cid cid_to_children = Hash.new { |h, k| h[k] = [] } root_customer_client = nil while unprocessed_customer_ids.size > 0 cid = unprocessed_customer_ids.pop response = google_ads_service.search( customer_id: cid, query: search_query, ) # Iterates over all rows in all pages to get all customer clients under # the specified customer's hierarchy. response.each do |row| customer_client = row.customer_client # The customer client that with level 0 is the specified customer if customer_client.level == 0 if root_customer_client == nil root_customer_client = customer_client end next end # For all level-1 (direct child) accounts that are a manager account, # the above query will be run against them to create a dictionary of # managers mapped to their child accounts for printing the hierarchy # afterwards. cid_to_children[cid.to_s] << customer_client unless customer_client.manager.nil? if !cid_to_children.key?(customer_client.id.to_s) && customer_client.level == 1 unprocessed_customer_ids << customer_client.id.to_s end end end end if root_customer_client puts "The hierarychy of customer ID #{root_customer_client.id} " + "is printed below:" print_account_hierarchy(root_customer_client, cid_to_children, 0) else puts "Customer ID #{manager_customer_id} is likely a test account, " \ "so its customer client information cannot be retrieved." end end end def print_account_hierarchy(customer_client, cid_to_children, depth) if depth == 0 puts 'Customer ID (Descriptive Name, Currency Code, Time Zone)' end customer_id = customer_client.id puts '-' * (depth * 2) + "#{customer_id} #{customer_client.descriptive_name} " + "#{customer_client.currency_code} #{customer_client.time_zone}" # Recursively call this function for all child accounts of customer_client if cid_to_children.key?(customer_id.to_s) cid_to_children[customer_id.to_s].each do |child| print_account_hierarchy(child, cid_to_children, depth + 1) end end end if __FILE__ == $PROGRAM_NAME options = {} # The following parameter(s) should be provided to run the example. You can # either specify these by changing the INSERT_XXX_ID_HERE values below, or on # the command line. # # Parameters passed on the command line will override any parameters set in # code. # # Running the example with -h will print the command line usage. options[:customer_id] = nil OptionParser.new do |opts| opts.banner = sprintf('Usage: ruby %s [options]', File.basename(__FILE__)) opts.separator '' opts.separator 'Options:' opts.on('-M', '--manager-customer-id MANAGER-CUSTOMER-ID', String, 'Manager Customer ID (optional)') do |v| options[:manager_customer_id] = v.tr("-", "") end opts.on('-L', '--login-customer-id LOGIN-CUSTOMER-ID', String, 'Login Customer ID (optional)') do |v| options[:login_customer_id] = v.tr("-", "") end opts.separator '' opts.separator 'Help:' opts.on_tail('-h', '--help', 'Show this message') do puts opts exit end end.parse! get_account_hierarchy(options[:manager_customer_id], options[:login_customer_id]) end ``` -------------------------------- ### Install Project Dependencies (app-start) Source: https://developers.google.com/cast/codelabs/cast-videos-ios Navigates to the 'app-start' directory and installs project dependencies using CocoaPods. This command should be run after downloading the sample code. ```bash cd app-start pod update pod install ``` -------------------------------- ### Get Start Index Source: https://developers.google.com/apps-script/reference/slides Returns the inclusive start index of the text range. ```APIDOC ## getStartIndex() ### Description Returns the inclusive, 0-based index for the first character in this range. ### Method Signature `getStartIndex()` ### Returns * **Integer** - The start index. ``` -------------------------------- ### Initialize Sample Data Files Source: https://developers.google.com/apps-script/samples/automations/import-csv-sheets Sets up the necessary Google Drive folders and creates sample CSV files for demonstrating the import process. This function should be run once to prepare the environment. ```javascript /** * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * This file contains functions that set up the folders and sample files used to demo the application. * * Sample data for the application is stored in the SampleData.gs file. */ // Global variables for sample setup. const INCLUDE_SAMPLE_DATA_FILES = true; // Set to true to create sample data files, false to skip. /** * Runs the setup for the sample. * 1) Creates the application folder and subfolders for unprocessed/processed CSV files. * from global variables APP_FOLDER | SOURCE_FOLDER | PROCESSED_FOLDER * 2) Creates the sample Sheets spreadsheet in the application folder. * from global variable SHEET_REPORT_NAME * 3) Creates CSV files from sample data in the unprocessed files folder. * from variable SAMPLE_DATA in SampleData.gs. * 4) Creates an installable trigger to run process automatically at a specified time interval. */ function setupSample() { console.log(`Application setup for: ${APP_TITLE}`); // Creates application folder. const folderAppPrimary = getApplicationFolder_(APP_FOLDER); // Creates supporting folders. const folderSource = getFolder_(SOURCE_FOLDER); const folderProcessed = getFolder_(PROCESSED_FOLDER); console.log( `Application folders: ${folderAppPrimary.getName()}, ${folderSource.getName()}, ${folderProcessed.getName()}`, ); if (INCLUDE_SAMPLE_DATA_FILES) { ``` -------------------------------- ### GET Profile Endpoint Example Source: https://developers.google.com/health/migration Example of calling the GET Profile endpoint using the Google Health API. The user ID can be specified directly or inferred using 'me'. ```http GET https://health.googleapis.com/v4/users/me/profile ``` -------------------------------- ### Basic HTTP Server Setup (Go) Source: https://developers.google.com/codelabs/maps-platform/full-stack-store-locator Sets up a basic Go web server to handle HTTP requests. It routes API requests to `dropoffsHandler` and static files to the `./static/` directory. ```go package main import ( "log" "net/http" "os" ) func main() { initConnectionPool() // Request for data should be handled by Go. Everything else should be directed // to the folder of static files. http.HandleFunc("/data/dropoffs", dropoffsHandler) http.Handle("/", http.FileServer(http.Dir("./static/aps"))) // Open up a port for the webserver. port := os.Getenv("PORT") if port == "" port = "8080" } log.Printf("Listening on port %s", port) if err := http.ListenAndServe(":"+port, nil); err != nil { log.Fatal(err) } } ``` -------------------------------- ### Get All-Day Start Date Source: https://developers.google.com/apps-script/class_calendarevent Retrieves the start date for an all-day calendar event. ```APIDOC ## getAllDayStartDate() ### Description Gets the date on which this all-day calendar event begins. ### Method `getAllDayStartDate()` ``` -------------------------------- ### Clone and Install Project Dependencies Source: https://developers.google.com/codelabs/mdc-102-web Clone the starter app from GitHub and install project dependencies using npm. This sets up the necessary environment for the codelab. ```bash git clone https://github.com/material-components/material-components-web-codelabs cd material-components-web-codelabs/mdc-102/starter npm install ``` -------------------------------- ### Initialize Google Ads Client and Run Example Source: https://developers.google.com/google-ads/api/samples/add-performance-max-product-listing-group-tree Initializes the Google Ads client from a properties file and runs the example to add a performance max product listing group tree. Handles potential file not found or IO exceptions during client initialization and Google Ads API exceptions during the request. ```java params.customerId = Long.parseLong("INSERT_CUSTOMER_ID_HERE"); params.assetGroupId = Long.parseLong("INSERT_AD_GROUP_ID_HERE"); // Optional: To replace the existing listing group tree from the asset group set this // parameter to true. // If the current AssetGroup already has a tree of ListingGroupFilters, attempting to add a // new set of ListingGroupFilters including a root filter will result in an // 'ASSET_GROUP_LISTING_GROUP_FILTER_ERROR_MULTIPLE_ROOTS' error. Setting this option to true // will remove the existing tree and prevent this error. params.replaceExistingTree = Boolean.parseBoolean("INSERT_REPLACE_EXISTING_TREE_HERE"); } GoogleAdsClient googleAdsClient = null; try { googleAdsClient = GoogleAdsClient.newBuilder().fromPropertiesFile().build(); } catch (FileNotFoundException fnfe) { System.err.printf( "Failed to load GoogleAdsClient configuration from file. Exception: %s%n", fnfe); System.exit(1); } catch (IOException ioe) { System.err.printf("Failed to create GoogleAdsClient. Exception: %s%n", ioe); System.exit(1); } try { new AddPerformanceMaxProductListingGroupTree() .runExample( googleAdsClient, params.customerId, params.assetGroupId, params.replaceExistingTree); } catch (GoogleAdsException gae) { // GoogleAdsException is the base class for most exceptions thrown by an API request. // Instances of this exception have a message and a GoogleAdsFailure that contains a // collection of GoogleAdsErrors that indicate the underlying causes of the // GoogleAdsException. System.err.printf( "Request ID %s failed due to GoogleAdsException. Underlying errors:%n", gae.getRequestId()); int i = 0; for (GoogleAdsError googleAdsError : gae.getGoogleAdsFailure().getErrorsList()) { System.err.printf(" Error %d: %s%n", i++, googleAdsError); } System.exit(1); } } ``` -------------------------------- ### Example Batch Request Source: https://developers.google.com/calendar/api/guides/batch This example demonstrates the structure of a batch request using a generic Farm API. It includes GET, PUT, and another GET request with different content types and headers. ```http POST /batch/farm/v1 HTTP/1.1 Authorization: Bearer your_auth_token Host: www.googleapis.com Content-Type: multipart/mixed; boundary=batch_foobarbaz Content-Length: total_content_length --batch_foobarbaz Content-Type: application/http Content-ID: GET /farm/v1/animals/pony --batch_foobarbaz Content-Type: application/http Content-ID: PUT /farm/v1/animals/sheep Content-Type: application/json Content-Length: part_content_length If-Match: "etag/sheep" { "animalName": "sheep", "animalAge": "5" "peltColor": "green", } --batch_foobarbaz Content-Type: application/http Content-ID: GET /farm/v1/animals If-None-Match: "etag/animals" --batch_foobarbaz-- ``` -------------------------------- ### Setup PHP Project for Google API Client Source: https://developers.google.com/accounts/docs/OAuth2WebServer Commands to set up a new PHP project directory and install the Google API Client library using Composer. ```bash mkdir ~/php-oauth2-example cd ~/php-oauth2-example ``` ```bash composer require google/apiclient:^2.15.0 ``` -------------------------------- ### Clone and Install MDC-103 Web Starter App Source: https://developers.google.com/codelabs/mdc-103-web Clone the starter app from GitHub and install project dependencies using npm. This sets up the development environment for the codelab. ```bash git clone https://github.com/material-components/material-components-web-codelabs cd material-components-web-codelabs/mdc-103/starter npm install ``` -------------------------------- ### Get installation source Source: https://developers.google.com/apps-script/reference/script/script-app Returns an enum value indicating how the script was installed as an add-on for the current user. ```javascript ScriptApp.getInstallationSource(); ``` -------------------------------- ### Run Local HTTP Server Source: https://developers.google.com/codelabs/maps-platform/google-maps-simple-store-locator Starts a simple HTTP server to preview the store locator application. Access the preview by navigating to the specified port in your browser. ```bash python3 -m http.server 8080 ``` -------------------------------- ### Userinfo Endpoint Request Example Source: https://developers.google.com/assistant/smarthome/develop/implement-oauth Example of a GET request to the userinfo endpoint, including the Authorization header. ```APIDOC ## GET /userinfo ### Description Retrieves basic profile information about the linked user. ### Method GET ### Endpoint /userinfo ### Headers - **Authorization** (string) - Required - The access token of type Bearer. ### Request Example ``` GET /userinfo HTTP/1.1 Host: myservice.example.com Authorization: Bearer ACCESS_TOKEN ``` ``` -------------------------------- ### Userinfo Endpoint Request Example Source: https://developers.google.com/assistant/smarthome/develop/implement-oauth This is an example of a GET request to the userinfo endpoint, including the Authorization header with a Bearer token. ```http GET /userinfo HTTP/1.1 Host: myservice.example.com Authorization: Bearer ACCESS_TOKEN ``` -------------------------------- ### Install Project Dependencies with npm Source: https://developers.google.com/codelabs/mdc-101-web Install the necessary project dependencies using npm from the starter directory. ```bash npm install ``` -------------------------------- ### Example entity report URL Source: https://developers.google.com/admin-sdk/reports/v1/guides/manage-usage-entities This is an example URL to get the entity report for a gplus_community entity with a specific entityKey and date. ```http https://admin.googleapis.com/admin/reports/v1/usage/gplus_communities/1234/dates/2017-12-11 ``` -------------------------------- ### SelectSingle Configuration Example Source: https://developers.google.com/apps-script/reference/data-studio/select-single This example demonstrates how to create a SelectSingle configuration element, set its properties, and add options to it. ```APIDOC const cc = DataStudioApp.createCommunityConnector(); const config = cc.getConfig(); const option1 = config.newOptionBuilder().setLabel('option label').setValue('option_value'); const option2 = config.newOptionBuilder().setLabel('second option label').setValue('option_value_2'); const info1 = config.newSelectSingle() .setId('api_endpoint') .setName('Data Type') .setHelpText('Select the data type you\'re interested in.') .setAllowOverride(true) .addOption(option1) .addOption(option2); ``` -------------------------------- ### Get the Starting Column of a Range Source: https://developers.google.com/apps-script/class_range Returns the starting column index of a given range within the spreadsheet. Logs the column number. ```javascript const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0]; const range = sheet.getRange('B2:D4'); Logger.log(range.getColumn()); ``` -------------------------------- ### Get BigQuery data source type Source: https://developers.google.com/apps-script/reference/spreadsheet/big-query-data-source-spec Retrieve the type of the data source. This example shows how to get the type after retrieving the specification. ```javascript // TODO(developer): Replace the URL with your own. const ss = SpreadsheetApp.openByUrl( 'https://docs.google.com/spreadsheets/d/abc123456/edit', ); const spec = ss.getDataSources()[0].getSpec(); const type = spec.getType(); ``` -------------------------------- ### Python Client Library Setup Source: https://developers.google.com/ad-manager/api/beta Install the Google Ad Manager client library from PyPi using pip. ```APIDOC ## Python Client Library Setup ### Description Install the Google Ad Manager client library from PyPi using pip. ### Code ```bash pip install google-ads-admanager ``` ``` -------------------------------- ### curl Example with Authorization Header Source: https://developers.google.com/identity/protocols/oauth2/service-account Example of using `curl` to make a GET request to the Drive Files API with the `Authorization: Bearer` header. ```APIDOC ## curl Example with Authorization Header ### Description This `curl` command demonstrates how to test the Drive Files API using the `Authorization: Bearer` HTTP header. ### Command ```bash curl -H "Authorization: Bearer access_token" https://www.googleapis.com/drive/v2/files ``` ``` -------------------------------- ### Install Pods and Create Workspace Source: https://developers.google.com/codelabs/maps-platform/location-places-ios Once the Podfile is configured, run 'pod install' in the terminal from your project directory. This installs the necessary SDKs and creates a .xcworkspace file for your project. ```bash pod install ``` -------------------------------- ### Installed Application client_secrets.json Example Source: https://developers.google.com/api-client-library/dotnet/guide/aaa_client_secrets This JSON structure is for installed applications. It requires client_id and client_secret, and typically includes redirect_uris, auth_uri, and token_uri. ```json { "installed": { "client_id": "837647042410-75ifg...usercontent.com", "client_secret":"asdlkfjaskd", "redirect_uris": ["http://localhost"], "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://accounts.google.com/o/oauth2/token" } } ``` -------------------------------- ### Configure LiteRT Samples Workspace Source: https://developers.google.com/codelabs/litert-image-segmentation-cpp Navigate to the LiteRT samples repository and run the configure script. Follow the prompts to set up the workspace for Android builds, selecting clang as the compiler and specifying NDK and SDK details. ```bash cd /path/to/litert-samples ./configure ``` -------------------------------- ### Example Authorization Endpoint Request Source: https://developers.google.com/assistant/smarthome/develop/implement-oauth This is an example of a GET request to your authorization endpoint. It includes parameters like client_id, redirect_uri, state, scope, and response_type. ```http GET https://myservice.example.com/auth?client_id=GOOGLE_CLIENT_ID&redirect_uri=REDIRECT_URI&state=STATE_STRING&scope=REQUESTED_SCOPES&response_type=code ``` -------------------------------- ### Install Deck.gl overlay library Source: https://developers.google.com/maps/documentation/javascript/libraries-open-source Install the Deck.gl library to use it as a custom Google Maps overlay. ```bash npm i @deck.gl/google-maps ``` -------------------------------- ### getIndex() Source: https://developers.google.com/apps-script/reference/spreadsheet/sheet Gets the position of the sheet in its parent spreadsheet. Starts at 1. ```APIDOC ## getIndex() ### Description Gets the position of the sheet in its parent spreadsheet. Starts at 1. ### Method `Sheet.getIndex()` ### Return `Integer` — The position of the sheet in its parent spreadsheet. ### Authorization Scripts that use this method require authorization with one or more of the following scopes: * `https://www.googleapis.com/auth/spreadsheets.currentonly` * `https://www.googleapis.com/auth/spreadsheets` ### Example ```javascript const ss = SpreadsheetApp.getActiveSpreadsheet(); // Note that the JavaScript index is 0, but this logs 1 const sheet = ss.getSheets()[0]; // ... because spreadsheets are 1-indexed Logger.log(sheet.getIndex()); ``` ``` -------------------------------- ### Start a Development Server with Python Source: https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side Use Python's built-in HTTP server to test your app locally. This is required because the IMA SDK loads dependencies using the same protocol as the page it's loaded from. Ensure you are in the directory containing your index.html file. ```bash python -m http.server 8000 ``` -------------------------------- ### Get Start Time Source: https://developers.google.com/apps-script/class_calendarevent Retrieves the date and time when the event begins. ```APIDOC ## getStartTime() ### Description Gets the date and time at which this calendar event begins. ### Method `getStartTime()` ``` -------------------------------- ### Run starter project with Webpack Dev Server Source: https://developers.google.com/codelabs/maps-platform/maps-deck-gl Run the starter project in your browser using Webpack Dev Server. This command starts the development server. ```bash npm start ``` -------------------------------- ### getApproximateLiveSeekableRangeStart Source: https://developers.google.com/android/reference/com/google/android/gms/cast/framework/media/RemoteMediaClient Gets the approximate start of the seekable range for a live stream. ```APIDOC ## getApproximateLiveSeekableRangeStart ### Description Returns the approximate start position (in milliseconds) of the live seekable range as calculated from the last received stream information and the elapsed wall-time since that update. ### Method ```java long getApproximateLiveSeekableRangeStart() ``` ``` -------------------------------- ### curl Example with Access Token Query Parameter Source: https://developers.google.com/identity/protocols/oauth2/service-account Example of using `curl` to make a GET request to the Drive Files API with the `access_token` query parameter. ```APIDOC ## curl Example with Access Token Query Parameter ### Description This `curl` command demonstrates an alternative way to test the Drive Files API using the `access_token` as a query string parameter. ### Command ```bash curl https://www.googleapis.com/drive/v2/files?access_token=access_token ``` ``` -------------------------------- ### Get Calendar Event Start Time - Apps Script Source: https://developers.google.com/apps-script/class_calendarevent Retrieves the start time of a calendar event. For all-day events, this is midnight of the start day in the calendar's time zone. Use `getAllDayStartDate()` for all-day events. ```javascript // Opens the calendar by its ID. You must have edit access to the calendar. // TODO(developer): Replace the ID with your own. const calendar = CalendarApp.getCalendarById( 'abc123456@group.calendar.google.com', ); // Gets the first event from the calendar for February 1st, 2023 that takes // place between 4:10 PM and 4:25 PM. const event = calendar.getEvents( new Date('Feb 01, 2023 16:10:00'), new Date('Feb 01, 2023 16:25:00'), )[0]; // Gets the date and time at which this calendar event begins and logs it. const startTime = event.getStartTime(); console.log(startTime); ``` -------------------------------- ### Clone Starter App from GitHub (Java) Source: https://developers.google.com/codelabs/mdc-101-java Clone the starter app repository from GitHub and checkout the specific branch for this codelab. This sets up the project structure for the tutorial. ```bash git clone https://github.com/material-components/material-components-android-codelabs cd material-components-android-codelabs/ git checkout 101-starter ```