Skip to content

Instantly share code, notes, and snippets.

@prasanthu
Created May 4, 2018 08:57
Show Gist options
  • Save prasanthu/393aa9228edd76ae6964f1a63afbfc9f to your computer and use it in GitHub Desktop.
Save prasanthu/393aa9228edd76ae6964f1a63afbfc9f to your computer and use it in GitHub Desktop.
let APIIdentifier = "http://google_api"
Auth0
.webAuth()
.audience(APIIdentifier)
.scope("openid profile email")
.connectionScope("email")
.start {
switch $0 {
case .failure(let error):
// Handle the error
print("Error: \(error)")
case .success(let credentials):
print("credentials: \(credentials)")
guard let accessToken = credentials.accessToken, let idToken = credentials.idToken else { return }
//print("accessToken: \(accessToken)")
HomeViewController.printToken(token: accessToken)
//print("idToken: \(idToken)")
HomeViewController.printToken(token: idToken)
SessionManager.shared.storeTokens(accessToken, idToken: idToken)
SessionManager.shared.retrieveProfile { error in
guard error == nil else {
return self.showLogin()
}
DispatchQueue.main.async {
self.performSegue(withIdentifier: "ShowProfileNonAnimated", sender: nil)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment