获取"无效的授权标头值格式"在Swift中使用Alamofire执行https请求

时间:2018-06-07 20:13:23

标签: ios swift rest authentication alamofire

代码是:

Alamofire.request(
    "https://...",
    method: .post,
    parameters: nil,
    encoding: URLEncoding.default,
    headers: [
        "Authorization": "Basic <client_id>:<client_secret>",
        "Content-Type": "application/x-www-form-urlencoded"
    ]
).responseString({ (response) in
    print(response)
})

打印语句打印:

{
    "error":"invalid_request",
    "error_description":"invalid authorization header value format"
}

The document声明标头参数应为:

  

授权:设置为Basic <base64 encoded "clientId:clientSecret">

     

内容类型:application / x-www-form-urlencoded

我在这里做错了什么?

0 个答案:

没有答案