【问题标题】:How to pass Token Key and Token Secret to Alamofire request?如何将 Token Key 和 Token Secret 传递给 Alamofire 请求?
【发布时间】:2017-09-24 17:04:51
【问题描述】:

我有 Consumer Key、Consumer Secret、Token Key 和 Token Secret 来获取 Data API。像邮递员这样:

我必须像上面的捕获邮递员一样获取我的 API 的数据。然后我有这样的 Alamofire 方法请求:

    Alamofire.request("https://conversation.8villages.com/1.0/contents/articles?state=published", headers: headers).responseJSON { response in
            print("test", response.request!)  // original URL request
            print("ini responseny", response.response!) // HTTP URL response
            print("test", response.data!)     // server data
            print("test", response.result)   // result of response serialization

            if let JSON = response.result.value {
                print("JSON: \(JSON)")
            }
        }

所以,我不知道如何在 get 方法中添加或传递我的令牌。请有人帮助我。

我正在使用 OAuthSwiftAlamofire

【问题讨论】:

    标签: ios swift oauth alamofire


    【解决方案1】:

    试试这个

    let headers: HTTPHeaders = [
        "Authorization": "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
        "Accept": "application/json"
    ]
    
    Alamofire.request("https://httpbin.org/headers", headers: headers).responseJSON { response in
        debugPrint(response)
    }
    

    【讨论】:

    • 我在哪里传递我的令牌?
    • 你可以传入 headers@fermendkis
    猜你喜欢
    • 2014-04-20
    • 1970-01-01
    • 2021-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-04
    • 1970-01-01
    • 2023-01-01
    相关资源
    最近更新 更多