Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View richieforeman's full-sized avatar
😻

Richie Foreman richieforeman

😻
View GitHub Profile
@richieforeman
richieforeman / exp.java
Last active April 20, 2020 18:47
exp.java
//// First, Implement an interface to intercept the HTTP Request before it goes out.
package com.google.java_scratch;
import com.google.api.client.auth.oauth2.Credential;
import com.google.api.client.http.HttpBackOffIOExceptionHandler;
import com.google.api.client.http.HttpBackOffUnsuccessfulResponseHandler;
import com.google.api.client.http.HttpBackOffUnsuccessfulResponseHandler.BackOffRequired;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.HttpResponse;
@richieforeman
richieforeman / reseller_list_customers.py
Last active August 29, 2015 14:22
Reseller List Customers
import csv
import httplib2
from argparse import ArgumentParser
from oauth2client.client import SignedJwtAssertionCredentials
from apiclient.discovery import build
SCOPES = [
'https://www.googleapis.com/auth/apps.order'
]
<!DOCTYPE html>
<html>
<head>
<title>JS Client Test Bench</title>
</head>
<body>
<script type="text/javascript">
var SETTINGS = {
CLIENT_ID: '801883730557-sm0htkeqruc79vm569f20gk8ponn62sv.apps.googleusercontent.com',
API_KEY: 'AIzaSyDobgkbnTo75Vb7XmgNBemxvbT_YKFTAPE',
import os
import httplib2
from apiclient.discovery import build
from oauth2client.client import SignedJwtAssertionCredentials
http = httplib2.Http()
SCOPES = [
'https://www.googleapis.com/auth/calendar'
]
/**
* A spreadsheet reading library that assumes that the first row is headers
* and provides a simple way to access, modify and append rows.
*/
var UberSheet = function(sheet) {
// Constants
this.HEADER_ROW_INDEX = 1;
this.HEADER_ROW_OFFSET = 1;
this.START_COLUMN = 1;
@richieforeman
richieforeman / reseller.rb
Last active August 29, 2015 14:15
Reseller Sample (Ruby)
require 'google/api_client'
client = Google::APIClient.new(
:application_name => 'Reseller Example!',
:application_version => '1.0.0'
)
RESELLER_ADMIN = '...'
PRIVATE_KEY_FILE = 'privatekey.p12'
@richieforeman
richieforeman / directory_sample.py
Created October 14, 2014 14:56
Directory Samples.
#!/usr/bin/python
#
# Copyright 2013 Google Inc. All Rights Reserved.
"""
DISCLAIMER:
(i) GOOGLE INC. ("GOOGLE") PROVIDES YOU ALL CODE HEREIN "AS IS" WITHOUT ANY
WARRANTIES OF ANY KIND, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING,
WITHOUT LIMITATION, ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
@richieforeman
richieforeman / tracing_token_sample.php
Last active January 8, 2016 16:32
Google API Tracing Token - PHP
$service = new Google_Service_Directory($googleClient);
// A tracing token can be utilizing with the PHP 1.0 library by passing an associative array to
// the '$optParams' value of the method call. The order of this parameter varies for each method call,
// but is typically immediately after the required arguments.
//
// The tracing token parameter will need to be added to EACH AND EVERY call where a tracing token is required.
$makeAdmin = new Google_Service_Directory_UserMakeAdmin();
$makeAdmin->setStatus(true);
$service->users->makeAdmin('marty.mcfly@timecircuit.org', $makeAdmin, array(
@richieforeman
richieforeman / tracing_token_example.py
Last active January 8, 2016 16:31
Google API Tracing Token - Python
service = build(serviceName="admin",
version="directory_v1",
http=httplib2.Http())
# A tracing token can be attached by utilizing the 'trace' kwarg on a method call.
# Switching the request to utilize all 'kwargs' is recommended.
#
# Importantly, when a request (such as the one below) includes a body parameter,
# the tracing token should NOT be included in the body.
#
@richieforeman
richieforeman / tracing_token_example.java
Last active January 8, 2016 16:33
Google API Tracing Token - Java
//// First, Implement an interface to intercept the HTTP Request before it goes out.
import java.io.IOException;
import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer;
public class TracingTokenInitializer implements GoogleClientRequestInitializer {
@Override
public void initialize(AbstractGoogleClientRequest<?> req) throws IOException {
System.out.println("Attaching tracing token...");
req.put("trace", "token:<<TOKEN GOES HERE>>");