No Description

FIRGitHubAuthCredential.m 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "FIRGitHubAuthCredential.h"
  17. #import "FIRGitHubAuthProvider.h"
  18. #import "FIRAuthExceptionUtils.h"
  19. #import "FIRVerifyAssertionRequest.h"
  20. NS_ASSUME_NONNULL_BEGIN
  21. @interface FIRGitHubAuthCredential ()
  22. - (nullable instancetype)initWithProvider:(NSString *)provider NS_UNAVAILABLE;
  23. @end
  24. @implementation FIRGitHubAuthCredential
  25. - (nullable instancetype)initWithProvider:(NSString *)provider {
  26. [FIRAuthExceptionUtils raiseMethodNotImplementedExceptionWithReason:
  27. @"Please call the designated initializer."];
  28. return nil;
  29. }
  30. - (nullable instancetype)initWithToken:(NSString *)token {
  31. self = [super initWithProvider:FIRGitHubAuthProviderID];
  32. if (self) {
  33. _token = [token copy];
  34. }
  35. return self;
  36. }
  37. - (void)prepareVerifyAssertionRequest:(FIRVerifyAssertionRequest *)request {
  38. request.providerAccessToken = _token;
  39. }
  40. #pragma mark - NSSecureCoding
  41. + (BOOL)supportsSecureCoding {
  42. return YES;
  43. }
  44. - (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
  45. NSString *token = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"token"];
  46. self = [self initWithToken:token];
  47. return self;
  48. }
  49. - (void)encodeWithCoder:(NSCoder *)aCoder {
  50. [aCoder encodeObject:self.token forKey:@"token"];
  51. }
  52. @end
  53. NS_ASSUME_NONNULL_END