ios - 如何使用 OAuth1Swift 验证具有读取、写入权限的 Trello API 用户

标签 ios swift trello

我正在尝试对获得对 Trello API 的读取、写入 访问权限的用户进行身份验证。我正在使用 OAuth1Swift 进行身份验证,但无法添加参数来添加权限和应用程序名称

我们如何添加这些参数?这是我的代码。

OAuthSwift Library

Trello API Docs

 func doOAuthTrello() {
    let oauthswift = OAuth1Swift(
        consumerKey:    "consumerKey",
        consumerSecret: "consumerSecret",
        requestTokenUrl:    "https://trello.com/1/OAuthGetRequestToken",
        authorizeUrl:       "https://trello.com/1/OAuthAuthorizeToken",
        accessTokenUrl:     "https://trello.com/1/OAuthGetAccessToken"
    )

    self.oauthswift = oauthswift
    oauthswift.authorizeURLHandler = getURLHandler()
    let _ = oauthswift.authorize(
        withCallbackURL: URL(string: "oauth-swift://oauth-callback/trello")!,
        success: { credential, response, parameters in
            self.showTokenAlert(name: serviceParameters["name"], credential: credential)
            self.testTrello(oauthswift)
        },
        failure: { error in
            print(error.localizedDescription, terminator: "")
        }
    )
}

最佳答案

在尝试了一切之后,这是解决方案:

lazy var paramaters:[String: String] = {
    return  [
        "consumerKey": "consumerKey",
        "consumerSecret": "consumerSecret",
        "requestTokenUrl": "https://trello.com/1/OAuthGetRequestToken?scope=read,write,account&expiration=never&name=AppName",
        "authorizeUrl": "https://trello.com/1/OAuthAuthorizeToken?scope=read,write,account&expiration=never&name=AppName",
        "accessTokenUrl": "https://trello.com/1/OAuthGetAccessToken?scope=read,write,account&expiration=never&name=AppName"
    ]
}()

通过向 url 参数添加 ?scope=read,write,account&expiration=never&name=AppName 来实现魔法

关于ios - 如何使用 OAuth1Swift 验证具有读取、写入权限的 Trello API 用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39791552/

相关文章:

Swift 3 反射 - 迭代属性

trello - 如何从卡片页面检索 Trello Board 短链接?

iphone - 使用IB自动重新定位UI元素

ios - IOS : Remove space between SearchBar and NavigationBar 上的 Xamarin.Forms

xcode - 使用 Swift 在 Storyboard之间切换

swift - 打印语句删除如何破坏我的项目? ( swift/Xcode)

api - 在 Trello API 中调用通知/全部/读取时请求未经授权的通知

javascript - Trello API 发布新卡错误 - 无法在 'postMessage' 上执行 'DOMWindow'

ios - 是否可以从我的 iOS 应用程序包中删除文件?

ios - UIImageView 不遵循设备方向