Skip to content

Commit

Permalink
fixes a crash while requesting a bearer token from some wifi hotspots h…
Browse files Browse the repository at this point in the history
  • Loading branch information
swissquote-nst committed Jan 22, 2014
1 parent 2489071 commit 54efe27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions STTwitter/STTwitterAppOnly.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

NS_ENUM(NSUInteger, STTwitterAppOnlyErrorCode) {
STTwitterAppOnlyCannotFindBearerTokenToBeInvalidated,
STTwitterAppOnlyCannotFindJSONInResponse,
STTwitterAppOnlyCannotFindBearerTokenInResponse
};

Expand Down
6 changes: 6 additions & 0 deletions STTwitter/STTwitterAppOnly.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ - (void)verifyCredentialsWithSuccessBlock:(void(^)(NSString *username))successBl
downloadProgressBlock:nil
successBlock:^(id request, NSDictionary *requestHeaders, NSDictionary *responseHeaders, id json) {

if([json isKindOfClass:[NSDictionary class]] == NO) {
NSError *error = [NSError errorWithDomain:NSStringFromClass([self class]) code:STTwitterAppOnlyCannotFindJSONInResponse userInfo:nil];
errorBlock(error);
return;
}

NSString *tokenType = [json valueForKey:@"token_type"];
if([tokenType isEqualToString:@"bearer"] == NO) {
NSError *error = [NSError errorWithDomain:NSStringFromClass([self class]) code:STTwitterAppOnlyCannotFindBearerTokenInResponse userInfo:@{NSLocalizedDescriptionKey : @"Cannot find bearer token in server response"}];
Expand Down

0 comments on commit 54efe27

Please sign in to comment.