Synchronized access to fetchedOauth2AccessToken

pull/16190/head
Muxi Yan 6 years ago
parent c6de16fc80
commit cb745ceaf9
  1. 8
      src/objective-c/GRPCClient/GRPCCall.m

@ -581,8 +581,12 @@ const char *kCFStreamVarName = "grpc_cfstream";
} }
NSMutableDictionary *headers = _requestHeaders; NSMutableDictionary *headers = _requestHeaders;
if (_fetchedOauth2AccessToken != nil) { __block NSString *fetchedOauth2AccessToken;
headers[@"authorization"] = [kBearerPrefix stringByAppendingString:_fetchedOauth2AccessToken]; @synchronized(self) {
fetchedOauth2AccessToken = _fetchedOauth2AccessToken;
}
if (fetchedOauth2AccessToken != nil) {
headers[@"authorization"] = [kBearerPrefix stringByAppendingString:fetchedOauth2AccessToken];
} else if (_callOptions.oauth2AccessToken != nil) { } else if (_callOptions.oauth2AccessToken != nil) {
headers[@"authorization"] = headers[@"authorization"] =
[kBearerPrefix stringByAppendingString:_callOptions.oauth2AccessToken]; [kBearerPrefix stringByAppendingString:_callOptions.oauth2AccessToken];

Loading…
Cancel
Save