diff options
author | Muxi Yan <muxi@users.noreply.github.com> | 2017-08-22 12:18:11 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-22 12:18:11 -0700 |
commit | e3d6a9a8d45d3180e28a529339f5661fe2526e0a (patch) | |
tree | 7ff83c81442a82a846fcc90e5d41bc81e36a9502 /src/objective-c/GRPCClient/GRPCCall+OAuth2.m | |
parent | a0a4272ec53ace03ad67bb9f79a0cf1e6d7bb583 (diff) | |
parent | b82f82b7251abc56bbe249644e1ee2f29956f4e2 (diff) |
Merge pull request #12180 from grpc/revert-12086-revert-11832-objc-oauth-protocol
Revert "Revert "Add OAuth2 protocol in GRPCClient""
Diffstat (limited to 'src/objective-c/GRPCClient/GRPCCall+OAuth2.m')
-rw-r--r-- | src/objective-c/GRPCClient/GRPCCall+OAuth2.m | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/objective-c/GRPCClient/GRPCCall+OAuth2.m b/src/objective-c/GRPCClient/GRPCCall+OAuth2.m index eaa7465087..8451ebe870 100644 --- a/src/objective-c/GRPCClient/GRPCCall+OAuth2.m +++ b/src/objective-c/GRPCClient/GRPCCall+OAuth2.m @@ -16,6 +16,8 @@ * */ +#import <objc/runtime.h> + #import "GRPCCall+OAuth2.h" static NSString * const kAuthorizationHeader = @"authorization"; @@ -23,6 +25,7 @@ static NSString * const kBearerPrefix = @"Bearer "; static NSString * const kChallengeHeader = @"www-authenticate"; @implementation GRPCCall (OAuth2) +@dynamic tokenProvider; - (NSString *)oauth2AccessToken { NSString *headerValue = self.requestHeaders[kAuthorizationHeader]; @@ -45,4 +48,12 @@ static NSString * const kChallengeHeader = @"www-authenticate"; return self.responseHeaders[kChallengeHeader]; } +- (void)setTokenProvider:(id<GRPCAuthorizationProtocol>)tokenProvider { + objc_setAssociatedObject(self, @selector(tokenProvider), tokenProvider, OBJC_ASSOCIATION_RETAIN); +} + +- (id<GRPCAuthorizationProtocol>)tokenProvider { + return objc_getAssociatedObject(self, @selector(tokenProvider)); +} + @end |