podio/podio-objc

Authenticate as user, wrong credentials not clear

Closed this issue · 4 comments

Code I'm trying to use:

PodioKit.setupWithAPIKey("bacon-development", secret: "long-generated-key-here")
PodioKit.authenticateAsUserWithEmail("hello", password: "abc", completion: {
    response, error in
    if !error {
        println("authenticated")
    } else {
        println("nope")
        println(error)
    }
})

and my log:

nope
Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: bad request (400)" UserInfo=0xca010e0 {NSErrorFailingURLKey=https://api.podio.com/oauth/token, com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0xca074f0> { URL: https://api.podio.com/oauth/token } { status code: 400, headers {
    "Content-Length" = 248;
    "Content-Type" = "application/json; charset=utf-8";
    Date = "Mon, 14 Jul 2014 13:27:53 GMT";
    Server = nginx;
    "X-Podio-Request-Id" = avzqzua3;
    "X-Rate-Limit-Limit" = 250;
    "X-Rate-Limit-Remaining" = 239;
} }, NSLocalizedDescription=Request failed: bad request (400)}

I'd expect an unauthorised 401 (given that I'm clearly not giving a valid user), but I'm getting 400.

Hi Dan,

It could be that the API is not accepting your API key. Is it possible for you to set a breakpoint in the completion block and print the body property of the response object passed in the completion block? That should have the output from the API describing the error.

We will soon be merging a branch with much better error reporting so that you can see exactly what is going on, but for now printing the body of the response should tell you the answer.

Hey Sebreh. I've edited the title of the issue to "Authenticate as user, wrong credentials not clear" since creating it, as I've discovered by putting valid credentials it does appear to work

Great. I'll close this issue once the new error reporting is merged then.

Dan, the commit with better NSErrors has now been merged to master (c4b7e06). I will now close this issue since your problem seems solved and you should have better error reporting now. Keep the feedback coming!