No Description

FIRFacebookAuthCredential.m 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 "FIRFacebookAuthCredential.h"
  17. #import "FIRFacebookAuthProvider.h"
  18. #import "FIRAuthExceptionUtils.h"
  19. #import "FIRVerifyAssertionRequest.h"
  20. NS_ASSUME_NONNULL_BEGIN
  21. @interface FIRFacebookAuthCredential ()
  22. - (nullable instancetype)initWithProvider:(NSString *)provider NS_UNAVAILABLE;
  23. @end
  24. @implementation FIRFacebookAuthCredential {
  25. NSString *_accessToken;
  26. }
  27. - (nullable instancetype)initWithProvider:(NSString *)provider {
  28. [FIRAuthExceptionUtils raiseMethodNotImplementedExceptionWithReason:
  29. @"Please call the designated initializer."];
  30. return nil;
  31. }
  32. - (nullable instancetype)initWithAccessToken:(NSString *)accessToken {
  33. self = [super initWithProvider:FIRFacebookAuthProviderID];
  34. if (self) {
  35. _accessToken = [accessToken copy];
  36. }
  37. return self;
  38. }
  39. - (void)prepareVerifyAssertionRequest:(FIRVerifyAssertionRequest *)request {
  40. request.providerAccessToken = _accessToken;
  41. }
  42. #pragma mark - NSSecureCoding
  43. + (BOOL)supportsSecureCoding {
  44. return YES;
  45. }
  46. - (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
  47. NSString *accessToken = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"accessToken"];
  48. self = [self initWithAccessToken:accessToken];
  49. return self;
  50. }
  51. - (void)encodeWithCoder:(NSCoder *)aCoder {
  52. [aCoder encodeObject:_accessToken forKey:@"accessToken"];
  53. }
  54. @end
  55. NS_ASSUME_NONNULL_END