Skip to content

Instantly share code, notes, and snippets.

Ian Barber ianbarber

Block or report user

Report or block ianbarber

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gsi.java
if (opr.isDone()) {
// If the user's cached credentials are valid, the OptionalPendingResult will be "done"
// and the GoogleSignInResult will be available instantly. We can try and retrieve an
// authentication code.
GoogleSignInResult result = opr.get();
handleSignInResult(result);
} else {
// If the user has not previously signed in on this device or the sign-in has expired,
// this asynchronous branch will attempt to sign in the user silently.
opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
View gsi.java
mGoogleApiClient = new GoogleApiClient.Builder(this /* Context */)

.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)

.addApi(Auth.GOOGLE_SIGN_IN_API, gso)

.build();

View gsi.java
OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);

View gsi.java
GoogleSignInAccount acct = googleSignInResult.getSignInAccount();
String authCode = acct.getServerAuthCode();
@ianbarber
ianbarber / ViewController.swift
Created Mar 17, 2015
ViewController for GIDSignIn example
View ViewController.swift
class ViewController: UIViewController, GIDSignInDelegate {
@IBOutlet weak var signInButton: GIDSignInButton!
override func viewDidLoad() {
super.viewDidLoad()
GIDSignIn.sharedInstance().delegate = self
// Test to see if we are signed in on load.
GIDSignIn.sharedInstance().signInSilently()
}
@ianbarber
ianbarber / AppDelegate.swift
Created Mar 17, 2015
Simple app delegate for Swift and GIDSignIn
View AppDelegate.swift
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
GIDSignIn.sharedInstance().clientID = "366667191730-38onttdkl2cpqstheip1ek3r5tb8s5ds.apps.googleusercontent.com";
return true
}
@ianbarber
ianbarber / drive.php
Created Mar 3, 2015
Query Drive with a service account
View drive.php
<?php
require_once "../vendor/autoload.php";
$client = new Google_Client();
$client->setApplicationName("Service Acccount Test");
$client_id = '985145966381-is5nq94smihmoa2k0567jab6u6vj278c.apps.googleusercontent.com';
$service_account_name = '985145966381-is5nq94smihmoa2k0567jab6u6vj278c@developer.gserviceaccount.com';
$key_file_location = 'foostarter-a27f84b2dec4.p12';
@ianbarber
ianbarber / analytics.php
Created Mar 3, 2015
Query Analytics with Service Account
View analytics.php
<?php
require_once "../vendor/autoload.php";
$client = new Google_Client();
$client->setApplicationName("Service Acccount Test");
$client_id = '985145966381-is5nq94smihmoa2k0567jab6u6vj278c.apps.googleusercontent.com';
$service_account_name = '985145966381-is5nq94smihmoa2k0567jab6u6vj278c@developer.gserviceaccount.com';
$key_file_location = 'foostarter-a27f84b2dec4.p12';
View gist:ea06ff3b15f4c24b2c72
[deviceManager launchApplication:applicationID
withLaunchOptions:[[GCKLaunchOptions alloc] initWithLanguageCode:nil
relaunchIfRunning:YES]];
View gist:1d8cc6ed1857c3144162
- (void)deviceDidGoOffline:(GCKDevice *)device {
[self performSelector:@selector(updateCastIconButtonStates) withObject:nil afterDelay:0];
}
You can’t perform that action at this time.