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(); |
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() | |
} |
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 | |
} |
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'; |
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]; | |
} |
NewerOlder