我正在开发一个 iPhone 应用程序,我需要在其中使用 hubspot 实现登录。为了实现这一点,我在 swift 中使用了 oauth2 库。在这个我使用下面的代码来做授权。当我运行该应用程序时,它会将我导航到 safari 并要求输入 Hubspot 的 ID 和密码。当我进入它时,它只会让我留在网站内并显示 3 个点正在加载。
{
let oauthswift = OAuth2Swift(
consumerKey: "****",
consumerSecret: "****",
authorizeUrl: "https://app.hubspot.com/oauth/authorize",
accessTokenUrl: "https://api.hubapi.com/oauth/v1/token",
responseType : "code"
)
oauthswift.authorize(withCallbackURL: URL(string: "myapp://"), scope: "contacts", state:"code", success: { (credentials, response, parameters) in
print(response as Any)
}, failure: { (error) in
print(error)
})
}