1

This question has been mentioned before ,but I have not found a working solution. I’m trying to replace these two methods in the Google Swift Quick Start Guide They no longer work because google has disabled use for embedded browsers

I added Google Sign in, but I’m not sure how to then link that to my Calendar API requests. Trying to keep it clean

// When the view appears, ensure that the Google Calendar API service is authorized
// and perform API calls
override func viewDidAppear(_ animated: Bool) {
    if let authorizer = service.authorizer,
        let canAuth = authorizer.canAuthorize, canAuth {
        fetchEvents()
    } else {
        present(
            createAuthController(),
            animated: true,
            completion: nil
        )
    }
}


private func createAuthController() -> GTMOAuth2ViewControllerTouch {
    let scopeString = scopes.joined(separator: " ")
    return GTMOAuth2ViewControllerTouch(
        scope: scopeString,
        clientID: kClientID,
        clientSecret: nil,
        keychainItemName: kKeychainItemName,
        delegate: self,
        finishedSelector: "viewController:finishedWithAuth:error:"
    )
}


// Creates the auth controller for authorizing access to Google Calendar API
private func createAuthController() -> GTMOAuth2ViewControllerTouch {
    let scopeString = scopes.joined(separator: " ")
    return GTMOAuth2ViewControllerTouch(
        scope: scopeString,
        clientID: kClientID,
        clientSecret: nil,
        keychainItemName: kKeychainItemName,
        delegate: self,
        finishedSelector: "viewController:finishedWithAuth:error:"
    )
}


// Handle completion of the authorization process, and update the Google Calendar API
// with the new credentials.
func viewController(vc : UIViewController,
                    finishedWithAuth authResult : GTMOAuth2Authentication, error : NSError?) {

    if let error = error {
        service.authorizer = nil
        showAlert(title: "Authentication Error", message: error.localizedDescription)
        return
    }

    service.authorizer = authResult
    dismiss(animated: true, completion: nil)
}
mparrish91
  • 101
  • 3
  • 11

0 Answers0