From 0c48f6d5ef62b901f63bc7a6f0bc284f035e9f66 Mon Sep 17 00:00:00 2001 From: Andrew Leung Date: Tue, 7 Jun 2016 13:43:40 -0700 Subject: [PATCH] Fix dropped 401 response when token present When a 401 response comes back to a request made with a token, if the WWW-Authenticate header does not contain the keywords "invalid_token" or "expired_token", the connection will get dropped silently because `- requestAccessAndRetryConnection:` expects no tokens. This fix adds an extra condition to ensure that it doesn't attempt to request access when the OAuth2Client's access token is present. The connection won't get dropped and the response handler will be called. --- Sources/OAuth2Client/NXOAuth2Connection.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/OAuth2Client/NXOAuth2Connection.m b/Sources/OAuth2Client/NXOAuth2Connection.m index 325177db..466f9374 100644 --- a/Sources/OAuth2Client/NXOAuth2Connection.m +++ b/Sources/OAuth2Client/NXOAuth2Connection.m @@ -424,7 +424,7 @@ - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLRespon { [self cancel]; [client refreshAccessTokenAndRetryConnection:self]; - } else if (client.authConnection != self && authenticateHeader && client) { + } else if (client.authConnection != self && authenticateHeader && client && !client.accessToken) { [self cancel]; [client requestAccessAndRetryConnection:self]; } else {