Created
May 4, 2018 08:57
-
-
Save prasanthu/393aa9228edd76ae6964f1a63afbfc9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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