Instamojo付款网关快速问题

时间:2019-03-18 09:46:14

标签: swift4.2

在Swift 4.2 xcode 10中的instamojo付款网关中生成访问令牌时,响应像无效的客户端一样来了。我正确传递了客户ID和客户机密。谁能告诉我我在做什么错。

这是我的代码

func generateAccessToken() {

    let queryItems = [NSURLQueryItem(name: "client_id", value: "test_RKVgV8Dxnh0nR5Kdpirbu1UGmFPqJpOmMuf"), NSURLQueryItem(name: "client_secret", value: "test_1X39GUfjlrPJL2QcJclXOYmsHWYw8iUaCQoyGqvZv5Tqzg6qvC6mT5QbvjZ6RSmPRMG7AsDxHhnLLEEG6HQXV1rtRxnS3fWcecEX6NVOqlV9fh3ER8tBZi733ys"), NSURLQueryItem(name: "grant_type", value: "client_credentials")]
    let urlComps = NSURLComponents(string: "https://api.instamojo.com/oauth2/token/")!
    urlComps.queryItems = queryItems as [URLQueryItem]
    let URL = urlComps.url!

    Alamofire.request(URL, method: .post, parameters: nil,encoding: JSONEncoding.default, headers: nil).responseJSON {
        response in
        switch response.result {
        case .success:
            print(response)

            break
        case .failure(let error):

            print(error)
        }
    } 
}

0 个答案:

没有答案