Skip to content

Commit 8cf8fdb

Browse files
author
Gavin Koehler
committed
Applied [patch](nxtbgthng#80) from @kangaroo5383
1 parent c31338f commit 8cf8fdb

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ profile
1616
*.moved-aside
1717
DerivedData
1818
.idea/
19+
*.patch

Sources/OAuth2Client/NXOAuth2Client.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,12 @@ - (void)oauthConnection:(NXOAuth2Connection *)connection didFailWithError:(NSErr
499499
NSString *body = [[NSString alloc] initWithData:connection.data encoding:NSUTF8StringEncoding];
500500
NSLog(@"oauthConnection Error: %@", body);
501501

502+
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:error.userInfo];
503+
if (connection.data) {
504+
[userInfo setObject:connection.data forKey:NXOAuth2ErrorResponseDataKey];
505+
}
506+
507+
NSError *updatedError = [NSError errorWithDomain:error.domain code:error.code userInfo:[NSDictionary dictionaryWithDictionary:userInfo]];
502508

503509
if (connection == authConnection) {
504510
self.authenticating = NO;
@@ -539,7 +545,7 @@ - (void)oauthConnection:(NXOAuth2Connection *)connection didFailWithError:(NSErr
539545
}
540546

541547
if ([delegate respondsToSelector:@selector(oauthClient:didFailToGetAccessTokenWithError:)]) {
542-
[delegate oauthClient:self didFailToGetAccessTokenWithError:error];
548+
[delegate oauthClient:self didFailToGetAccessTokenWithError:updatedError];
543549
}
544550
}
545551
}

Sources/OAuth2Client/NXOAuth2Constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,4 @@ typedef enum {
106106

107107

108108
extern NSString * const NXOAuth2AccountStoreErrorKey;
109-
109+
extern NSString * const NXOAuth2ErrorResponseDataKey;

Sources/OAuth2Client/NXOAuth2Constants.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@
3838
#pragma mark UserInfo Keys
3939

4040
NSString * const NXOAuth2AccountStoreErrorKey = @"NXOAuth2AccountStoreErrorKey";
41+
NSString * const NXOAuth2ErrorResponseDataKey = @"NXOAuth2ErrorResponseDataKey";

0 commit comments

Comments
 (0)