![](/img/trans.png)
[英]How to send request in Alamofire with parameters and headers using POST method in swift
[英]How to send token string (jwt) as Cookie in Alamofire Post request in swift?
我想传递一个令牌,它是一个jwt(json网络令牌),类似于
?eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..vNLenIyy1bdLShrNZHx7mKfbvJmDKsMEEsk2EIHYis0
并为String格式。 我想将此令牌作为Cookie传递给Alamofire POST请求中的API。 请任何帮助将不胜感激。
您可以尝试在会话中设置HTTPCookieStorage。
迅捷2
let properties = [
NSHTTPCookieDomain: "httpbin.org",
NSHTTPCookiePath: "/post",
NSHTTPCookieName: "foo",
NSHTTPCookieValue: "bar",
]
let cookie = NSHTTPCookie(properties: properties)!
manager.session.configuration.HTTPCookieStorage?.setCookie(cookie)
迅捷3
let properties = [
HTTPCookiePropertyKey.domain: "httpbin.org",
HTTPCookiePropertyKey.path: "/post",
HTTPCookiePropertyKey.name: "foo",
HTTPCookiePropertyKey.value: "bar",
]
let cookie = HTTPCookie(properties: properties)!
manager.session.configuration.httpCookieStorage?.setCookie(cookie)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.