Skip to content

Instantly share code, notes, and snippets.

@kgleong
Last active January 1, 2019 01:35
Show Gist options
  • Select an option

  • Save kgleong/27f9fe32a115c64a3b67b5f77ef2a524 to your computer and use it in GitHub Desktop.

Select an option

Save kgleong/27f9fe32a115c64a3b67b5f77ef2a524 to your computer and use it in GitHub Desktop.
Google Drive - View Controller - Authorizer
import GTMSessionFetcher
extension ViewController: GIDSignInDelegate, GIDSignInUIDelegate {
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
// A nil error indicates a successful login
if error == nil {
// Use the authenticated user's credentials when querying the Google Drive API.
self.googleDriveService.authorizer = user.authentication.fetcherAuthorizer()
} else {
self.googleDriveService.authorizer = nil
}
googleSignInButton.isHidden = error == nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment