From 8986cfe6259fe7efc6ad438abb9e904f190c0515 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 23 Oct 2018 10:39:39 -0700 Subject: [PATCH] Assert mutual exclusion of authTokenProvider and oauth2AccessToken --- src/objective-c/GRPCClient/GRPCCall.m | 3 +++ src/objective-c/GRPCClient/GRPCCallOptions.h | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 29a0ed4e106..85a2837336d 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -781,6 +781,9 @@ const char *kCFStreamVarName = "grpc_cfstream"; } _callOptions = callOptions; } + + NSAssert(_callOptions.authTokenProvider != nil || _callOptions.oauth2AccessToken != nil, + @"authTokenProvider and oauth2AccessToken cannot be set at the same time"); if (_callOptions.authTokenProvider != nil) { @synchronized(self) { self.isWaitingForToken = YES; diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.h b/src/objective-c/GRPCClient/GRPCCallOptions.h index 4c8bb605eab..27834b20088 100644 --- a/src/objective-c/GRPCClient/GRPCCallOptions.h +++ b/src/objective-c/GRPCClient/GRPCCallOptions.h @@ -91,8 +91,8 @@ typedef NS_ENUM(NSInteger, GRPCTransportType) { /** * The OAuth2 access token string. The string is prefixed with "Bearer " then used as value of the - * request's "authorization" header field. This parameter takes precedence over \a - * oauth2AccessToken. + * request's "authorization" header field. This parameter should not be used simultaneously with + * \a authTokenProvider. */ @property(copy, readonly) NSString *oauth2AccessToken; @@ -245,7 +245,7 @@ typedef NS_ENUM(NSInteger, GRPCTransportType) { /** * The interface to get the OAuth2 access token string. gRPC will attempt to acquire token when - * initiating the call. This parameter takes precedence over \a oauth2AccessToken. + * initiating the call. This parameter should not be used simultaneously with \a oauth2AccessToken. */ @property(readwrite) id authTokenProvider;