Skip to content

Instantly share code, notes, and snippets.

@kgleong
Last active January 19, 2019 17:13
Show Gist options
  • Select an option

  • Save kgleong/4db44436a122aa2465b41a69a7f4ceda to your computer and use it in GitHub Desktop.

Select an option

Save kgleong/4db44436a122aa2465b41a69a7f4ceda to your computer and use it in GitHub Desktop.
Google Drive - Set Authorizer and User
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 {
// Include authorization headers/values with each Drive API request.
self.googleDriveService.authorizer = user.authentication.fetcherAuthorizer()
self.googleUser = user
} else {
self.googleDriveService.authorizer = nil
self.googleUser = nil
}
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment