会话已过期或在Swift 4.2中无效

时间:2018-12-03 09:10:46

标签: alamofire access-token rest-client swift4.2

团队

我们正在使用外部api获取access_Token,并使用access_token使用授权标头获取数据。以下是用于发送授权的代码。

当我们在Rest Client(Firefox)和Andriod(Retrofit)中使用相同的Access_token时,我们能够做出正确的响应并正常工作。但是在Swift中,我们遇到了问题

缺少什么?

  

let headers1:HTTPHeaders = [                  “ Content-Type”:“ application / json”,                  “ Accept”:“ application / json”,                  “授权”:“承载者” Accesstoken值动态发送“)”              ]

   Alamofire.request(url, method: .get, parameters: nil, encoding: JSONEncoding.default, headers: headers1).responseJSON { response in
       debugPrint(response)
   }
     

[请求]:GET https://someUrl

     

[响应]:{URL:https://someurl   } {状态代码:401,标头{“ Cache-Control” =(          “无缓存,必须重新验证,最大年龄= 0,无存储,私有”); “内容安全策略” =(          “升级不安全的请求”); “内容类型” =(          “ application / json; charset = UTF-8”);日期=(          “ 2018年12月3日星期一08:59:31 GMT”); “ Expect-CT” =(          “” max-age = 0; report-uri = \“ https://calm-dawn-26291.herokuapp.com/Expect-CT-report/00D6F000001G1ism \”;“   ); “仅公开密钥销报告” =(          “;” pin-sha256 = \“ 9n0izTnSRF + W4W4JTq51avSXkWhQB8duS2bxVLfzXsY = \”; pin-sha256 = \“ 5kJvNEMw0KjrCAu7eXY5HZdvyCS13BbA0VJG1RSP91w = \”;   pin-sha256 = \“ njN4rRG + 22dNXAi + yb8e3UMypgzPUPHlv4 + foULwl1g = \”;   最大年龄= 86400; includeSubDomains;   report-uri = \“ https://calm-dawn-26291.herokuapp.com/hpkp-report/00D6F000001G1ism \”;“   ); “严格的运输安全” =(          “ max-age = 31536002; includeSubDomains”); “传输编码” =(          身份); “ Www-Authenticate” =(          令牌); “ X-Content-Type-Options” =(          nosniff); “ X-Robots-Tag” =(          没有 ); “ X-XSS-Protection” =(          “ 1; mode = block”); }} [数据]:75个字节[结果]:成功:(          {          errorCode =“ INVALID_SESSION_ID”;          message =“会话已过期或无效”; })[时间轴]:时间轴:{“请求开始时间”:565520370.377,“初始响应   时间”:565520371.593,“请求完成时间”:565520371.594,   “序列化完成时间”:565520371.595,“延迟”:1.216秒,   “请求持续时间”:1.217秒,“序列化持续时间”:0.001秒,   “总持续时间”:1.218秒}

0 个答案:

没有答案