nxtbgthng / OAuth2Client

Client library for OAuth2 (currently built against draft 10 of the OAuth2 spec)
855 stars 217 forks source link

Crash in accountsFromDefaultKeychain assert #197

Open GabeJacobs opened 8 years ago

GabeJacobs commented 8 years ago

I often get a crash when booting up my app at the NSAssert in this block in the NXOAuth2AccountStore class.

+ (NSDictionary *)accountsFromDefaultKeychain;
{
    NSString *serviceName = [self keychainServiceName];

    NSDictionary *result = nil;
    NSDictionary *query = [NSDictionary dictionaryWithObjectsAndKeys:
                           (__bridge NSString *)kSecClassGenericPassword, kSecClass,
                           serviceName, kSecAttrService,
                           kCFBooleanTrue, kSecReturnAttributes,
                           nil];
    CFTypeRef cfResult = nil;
    OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &cfResult);
    result = (__bridge_transfer NSDictionary *)cfResult;

    if (status != noErr) {
       NSAssert1(status == errSecItemNotFound, @"Unexpected error while fetching accounts from keychain: %ld", status);
        return nil;
    }

    return [NSKeyedUnarchiver unarchiveObjectWithData:[result objectForKey:(__bridge NSString *)kSecAttrGeneric]];
}

Here is the error:

2015-11-17 12:57:59.550 Cymbal[15805:4161141] *** Assertion failure in +[NXOAuth2AccountStore accountsFromDefaultKeychain], /Users/gabejacobs/Desktop/Anthem-iOS/Pods/NXOAuth2Client/Sources/OAuth2Client/NXOAuth2AccountStore.m:583

any clue?

sirnacnud commented 8 years ago

I think this is the same issue as #188