【问题标题】:How to authenticate Trello API user with read, write permissions using OAuth1Swift如何使用 OAuth1Swift 验证具有读、写权限的 Trello API 用户
【发布时间】:2016-09-30 22:23:32
【问题描述】:

我正在尝试对获得 read, write 访问 Trello API 权限的用户进行身份验证。我正在使用OAuth1Swift 进行身份验证,但无法添加参数以添加权限和app name

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

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: "")
        }
    )
}

【问题讨论】:

    标签: ios swift trello


    【解决方案1】:

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

    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 来实现魔法

    【讨论】:

      猜你喜欢
      • 2015-09-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-23
      • 1970-01-01
      • 2018-12-31
      • 2016-10-11
      • 2014-03-20
      • 2015-09-07
      相关资源
      最近更新 更多