trivago / Heimdallr.swift

Easy to use OAuth 2 library for iOS, written in Swift.
Apache License 2.0
639 stars 86 forks source link

authenticateRequest in README #84

Closed nicholas12345 closed 8 years ago

nicholas12345 commented 8 years ago

Hi, I am having a bit of hard time to implement authenticateRequest. From README file, first, in .Success(let request) shouldn't "let" be removed? Having it causes crashes. Also, switch requires default case. In the end, for some reason even if I get .Success(request) back, for some to me unknown reason, code enters in default instead on .Success. Some working example or snippet might be good to have.

Here is what I have:

heimdallr.authenticateRequest(request) {
  result in 
  switch result {
    case .Success(request):
      let task = session.dataTaskWithRequest(request) {
        data, response, error in
        // deserialize data and see response code
     }
     task.resume()
   case .Failure(let error): 
    // print error
   default:
     print("Why I entered here!?")`

Can you help me out here, please?
nicholas12345 commented 8 years ago

Closing, problem was uninitialized session variable.