diff --git a/Source/AppAuthCore/OIDAuthState.m b/Source/AppAuthCore/OIDAuthState.m index fe8a16221..eaef49d3e 100644 --- a/Source/AppAuthCore/OIDAuthState.m +++ b/Source/AppAuthCore/OIDAuthState.m @@ -472,13 +472,17 @@ - (void)performActionWithFreshTokens:(OIDAuthStateAction)action (nullable NSDictionary *)additionalParameters dispatchQueue:(dispatch_queue_t)dispatchQueue { - if ([self isTokenFresh]) { - // access token is valid within tolerance levels, perform action - dispatch_async(dispatchQueue, ^{ - action(self.accessToken, self.idToken, nil); - }); - return; - } + NSString * accessToken = self.accessToken; + NSString * idToken = self.idToken; + void (^block)(void) = ^(void){ + action(accessToken, idToken, nil); + }; + + if ([self isTokenFresh]) { + // access token is valid within tolerance levels, perform action + dispatch_async(dispatchQueue, block); + return; + } if (!_refreshToken) { // no refresh token available and token has expired