FIRVerifyCustomTokenRequest.m 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 "FIRVerifyCustomTokenRequest.h"
  17. /** @var kVerifyCustomTokenEndpoint
  18. @brief The "verifyPassword" endpoint.
  19. */
  20. static NSString *const kVerifyCustomTokenEndpoint = @"verifyCustomToken";
  21. /** @var kTokenKey
  22. @brief The key for the "token" value in the request.
  23. */
  24. static NSString *const kTokenKey = @"token";
  25. /** @var kReturnSecureTokenKey
  26. @brief The key for the "returnSecureToken" value in the request.
  27. */
  28. static NSString *const kReturnSecureTokenKey = @"returnSecureToken";
  29. @implementation FIRVerifyCustomTokenRequest
  30. - (nullable instancetype)initWithToken:(NSString *)token
  31. APIKey:(NSString *)APIKey {
  32. self = [super initWithEndpoint:kVerifyCustomTokenEndpoint APIKey:APIKey];
  33. if (self) {
  34. _token = [token copy];
  35. _returnSecureToken = YES;
  36. }
  37. return self;
  38. }
  39. - (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
  40. NSMutableDictionary *body = [@{
  41. kTokenKey : _token
  42. } mutableCopy];
  43. if (_returnSecureToken) {
  44. body[kReturnSecureTokenKey] = @YES;
  45. }
  46. return body;
  47. }
  48. @end