Guest User

Untitled

a guest
May 20th, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. override func viewDidAppear(_ animated: Bool) {
  2. let keychain = Keychain(service: "kfurue.RxSwiftRailsTutorial-token")
  3.  
  4. if keychain["oauthToken"] == nil {
  5. oauthswift.authorizeURLHandler = SafariURLHandler(viewController: self, oauthSwift: oauthswift)
  6. oauthswift.authorize(
  7. withCallbackURL: URL(string: "sample-app://oauth-callback")!,
  8. scope: "", state: "hoge",
  9. success: { credential, _, _ in
  10. print(credential.oauthToken)
  11. // OAuthSwiftで取得したトークンをKeychainにストアする
  12. keychain["oauthToken"] = credential.oauthToken
  13. },
  14. failure: { error in
  15. print(error.localizedDescription)
  16. }
  17. )
  18. }
  19.  
  20. }
Add Comment
Please, Sign In to add comment