diff options
-rw-r--r-- | src/objective-c/GRPCClient/GRPCCall.m | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index daa7e8dd4a..34a0e436ea 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -581,8 +581,12 @@ const char *kCFStreamVarName = "grpc_cfstream"; } NSMutableDictionary *headers = _requestHeaders; - if (_fetchedOauth2AccessToken != nil) { - headers[@"authorization"] = [kBearerPrefix stringByAppendingString:_fetchedOauth2AccessToken]; + __block NSString *fetchedOauth2AccessToken; + @synchronized(self) { + fetchedOauth2AccessToken = _fetchedOauth2AccessToken; + } + if (fetchedOauth2AccessToken != nil) { + headers[@"authorization"] = [kBearerPrefix stringByAppendingString:fetchedOauth2AccessToken]; } else if (_callOptions.oauth2AccessToken != nil) { headers[@"authorization"] = [kBearerPrefix stringByAppendingString:_callOptions.oauth2AccessToken]; |