Showing
1 changed file
with
60 additions
and
12 deletions
... | @@ -1168,10 +1168,26 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1168,10 +1168,26 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1168 | NSDictionary *postDictionary3 = @{@"client_id": clientId, @"client_secret": clientSecret, @"refresh_token": refreshToken, @"grant_type":@"refresh_token", }; | 1168 | NSDictionary *postDictionary3 = @{@"client_id": clientId, @"client_secret": clientSecret, @"refresh_token": refreshToken, @"grant_type":@"refresh_token", }; |
1169 | NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:postDictionary3 options:0 error:NULL]; | 1169 | NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:postDictionary3 options:0 error:NULL]; |
1170 | [self sendContext5:jsonData3 successBlock:^(NSDictionary *contextResponse) { | 1170 | [self sendContext5:jsonData3 successBlock:^(NSDictionary *contextResponse) { |
1171 | - if (success) { | 1171 | + if (success && ([_db tableExists:@"requestVariables"] == YES)) { |
1172 | - [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [contextResponse objectForKey:@"access_token"], [contextResponse objectForKey:@"refresh_token"]]; | 1172 | +// [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [contextResponse objectForKey:@"access_token"], [contextResponse objectForKey:@"refresh_token"]]; |
1173 | - NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; | 1173 | +// NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; |
1174 | - success(successResponse); | 1174 | +// success(successResponse); |
1175 | + | ||
1176 | + @try { | ||
1177 | + [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [contextResponse objectForKey:@"access_token"], [contextResponse objectForKey:@"refresh_token"]]; | ||
1178 | + NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; | ||
1179 | + success(successResponse); | ||
1180 | + } | ||
1181 | + @catch (NSException *exception) { | ||
1182 | + NSLog(@"UPDATE Token error: %@", exception.reason); | ||
1183 | + if (failure) { | ||
1184 | + NSError *error = nil; | ||
1185 | + failure(error); | ||
1186 | + } | ||
1187 | + } | ||
1188 | + @finally { | ||
1189 | + // NSLog(@"Finally condition"); | ||
1190 | + } | ||
1175 | } | 1191 | } |
1176 | } failureBlock:^(NSError *error) { | 1192 | } failureBlock:^(NSError *error) { |
1177 | if (failure) { | 1193 | if (failure) { |
... | @@ -1239,10 +1255,26 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1239,10 +1255,26 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1239 | NSDictionary *postDictionary3 = @{@"client_id": clientId, @"client_secret": clientSecret, @"refresh_token": refreshToken, @"grant_type":@"refresh_token", }; | 1255 | NSDictionary *postDictionary3 = @{@"client_id": clientId, @"client_secret": clientSecret, @"refresh_token": refreshToken, @"grant_type":@"refresh_token", }; |
1240 | NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:postDictionary3 options:0 error:NULL]; | 1256 | NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:postDictionary3 options:0 error:NULL]; |
1241 | [self sendContext5:jsonData3 successBlock:^(NSDictionary *contextResponse) { | 1257 | [self sendContext5:jsonData3 successBlock:^(NSDictionary *contextResponse) { |
1242 | - if (success) { | 1258 | + if (success && ([_db tableExists:@"requestVariables"] == YES)) { |
1243 | - [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [contextResponse objectForKey:@"access_token"], [contextResponse objectForKey:@"refresh_token"]]; | 1259 | +// [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [contextResponse objectForKey:@"access_token"], [contextResponse objectForKey:@"refresh_token"]]; |
1244 | - NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; | 1260 | +// NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; |
1245 | - success(successResponse); | 1261 | +// success(successResponse); |
1262 | + | ||
1263 | + @try { | ||
1264 | + [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [contextResponse objectForKey:@"access_token"], [contextResponse objectForKey:@"refresh_token"]]; | ||
1265 | + NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; | ||
1266 | + success(successResponse); | ||
1267 | + } | ||
1268 | + @catch (NSException *exception) { | ||
1269 | + NSLog(@"UPDATE Token error: %@", exception.reason); | ||
1270 | + if (failure) { | ||
1271 | + NSError *error = nil; | ||
1272 | + failure(error); | ||
1273 | + } | ||
1274 | + } | ||
1275 | + @finally { | ||
1276 | + // NSLog(@"Finally condition"); | ||
1277 | + } | ||
1246 | } | 1278 | } |
1247 | } failureBlock:^(NSError *error) { | 1279 | } failureBlock:^(NSError *error) { |
1248 | if (failure) { | 1280 | if (failure) { |
... | @@ -1310,10 +1342,26 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1310,10 +1342,26 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1310 | NSDictionary *postDictionary3 = @{@"client_id": clientId, @"client_secret": clientSecret, @"refresh_token": refreshToken, @"grant_type":@"refresh_token", }; | 1342 | NSDictionary *postDictionary3 = @{@"client_id": clientId, @"client_secret": clientSecret, @"refresh_token": refreshToken, @"grant_type":@"refresh_token", }; |
1311 | NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:postDictionary3 options:0 error:NULL]; | 1343 | NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:postDictionary3 options:0 error:NULL]; |
1312 | [self sendContext5:jsonData3 successBlock:^(NSDictionary *contextResponse) { | 1344 | [self sendContext5:jsonData3 successBlock:^(NSDictionary *contextResponse) { |
1313 | - if (success) { | 1345 | + if (success && ([_db tableExists:@"requestVariables"] == YES)) { |
1314 | - [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [contextResponse objectForKey:@"access_token"], [contextResponse objectForKey:@"refresh_token"]]; | 1346 | +// [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [contextResponse objectForKey:@"access_token"], [contextResponse objectForKey:@"refresh_token"]]; |
1315 | - NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; | 1347 | +// NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; |
1316 | - success(successResponse); | 1348 | +// success(successResponse); |
1349 | + | ||
1350 | + @try { | ||
1351 | + [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [contextResponse objectForKey:@"access_token"], [contextResponse objectForKey:@"refresh_token"]]; | ||
1352 | + NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; | ||
1353 | + success(successResponse); | ||
1354 | + } | ||
1355 | + @catch (NSException *exception) { | ||
1356 | + NSLog(@"UPDATE Token error: %@", exception.reason); | ||
1357 | + if (failure) { | ||
1358 | + NSError *error = nil; | ||
1359 | + failure(error); | ||
1360 | + } | ||
1361 | + } | ||
1362 | + @finally { | ||
1363 | + // NSLog(@"Finally condition"); | ||
1364 | + } | ||
1317 | } | 1365 | } |
1318 | } failureBlock:^(NSError *error) { | 1366 | } failureBlock:^(NSError *error) { |
1319 | if (failure) { | 1367 | if (failure) { | ... | ... |
-
Please register or login to post a comment