【问题标题】:Square API + OAuth: How do I sign out of my iPad app?Square API + OAuth:如何退出我的 iPad 应用程序?
【发布时间】:2016-11-23 03:52:30
【问题描述】:

我正在使用 Swift 和 OAuthSwift pod 使用应用程序内的 SFSafariViewController 来处理 OAuth。这是登录的样子:

问题是,当我尝试使用此代码注销时:

  @IBAction func signOutButtonPressed(_ sender: AnyObject) {
    let svc = SFSafariViewController(url: URL(string: "https://squareup.com/logout")!)
    self.present(svc, animated: true, completion: {
      print("signed outttt")
      appStore.dispatch(AppAction(type: .MerchantLogout()))
    })
  }

它再次打开浏览器并显示该页面。用户已成功注销(cookie 已重置等),但我希望浏览器关闭而不是再次显示登录表单。通过该表单登录不会调用我的 OAuth 回调。相反,它只是让他们登录并将他们发送到方形仪表板。

使用应用内 SFSafariViewController + OAuth 注销用户的正确方法是什么?

【问题讨论】:

  • 为什么要退出?
  • 如果有登录方式,也应该有退出方式

标签: ios swift oauth square-connect


【解决方案1】:

最终我还是这样做了:

  @IBAction func signOutButtonPressed(_ sender: AnyObject) {
    let svc = SFSafariViewController(url: URL(string: "https://squareup.com/logout")!)

    self.present(svc, animated: true, completion: {
      appStore.dispatch(AppAction(type: .MerchantLogout()))
      self.dismiss(animated: false, completion: nil)
    })
  }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多