FIRVerifyCustomTokenRequest.m 2.0 KB

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