Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let postData = NSMutableData(data: "username=james+jypsee@jypsee.com".data(using: .utf8)!)
- postData.append("&password=redacted".data(using: .utf8)!)
- postData.append("&grant_type=password".data(using: .utf8)!)
- postData.append("&client_id=redacted".data(using: .utf8)!)
- postData.append("&client_secret=redacted".data(using: .utf8)!)
- let request = NSMutableURLRequest(url: NSURL(string: "https://redacted.com/api/oauth2/token/")! as URL,
- cachePolicy: .useProtocolCachePolicy,
- timeoutInterval: 10.0)
- request.httpMethod = "POST"
- request.allHTTPHeaderFields = headers
- request.httpBody = postData as Data
- let session = URLSession.shared
- let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
- if (error != nil) {
- print(error)
- } else {
- let httpResponse = response as? HTTPURLResponse
- print(httpResponse)
- }
- })
Add Comment
Please, Sign In to add comment