FIRGetRecaptchaConfigRequest.m 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright 2022 Google LLC
  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/FIRGetRecaptchaConfigRequest.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. static NSString *const kRecaptchaVersion = @"RECAPTCHA_ENTERPRISE";
  19. /** @var kGetRecaptchaConfigEndpoint
  20. @brief The "getRecaptchaConfig" endpoint.
  21. */
  22. static NSString *const kGetRecaptchaConfigEndpoint = @"recaptchaConfig";
  23. /** @var kClientType
  24. @brief The key for the "clientType" value in the request.
  25. */
  26. static NSString *const kClientTypeKey = @"clientType";
  27. /** @var kVersionKey
  28. @brief The key for the "version" value in the request.
  29. */
  30. static NSString *const kVersionKey = @"version";
  31. /** @var kTenantIDKey
  32. @brief The key for the tenant id value in the request.
  33. */
  34. static NSString *const kTenantIDKey = @"tenantId";
  35. @implementation FIRGetRecaptchaConfigRequest
  36. - (nullable instancetype)initWithRequestConfiguration:
  37. (nonnull FIRAuthRequestConfiguration *)requestConfiguration {
  38. requestConfiguration.HTTPMethod = @"GET";
  39. self = [super initWithEndpoint:kGetRecaptchaConfigEndpoint
  40. requestConfiguration:requestConfiguration];
  41. self.useIdentityPlatform = YES;
  42. return self;
  43. }
  44. - (BOOL)containsPostBody {
  45. return NO;
  46. }
  47. - (nullable NSString *)queryParams {
  48. NSMutableString *queryParams = [[NSMutableString alloc] init];
  49. [queryParams appendFormat:@"&%@=%@&%@=%@", kClientTypeKey, self.clientType, kVersionKey,
  50. kRecaptchaVersion];
  51. if (self.tenantID) {
  52. [queryParams appendFormat:@"&%@=%@", kTenantIDKey, self.tenantID];
  53. }
  54. return queryParams;
  55. }
  56. - (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
  57. return nil;
  58. }
  59. @end
  60. NS_ASSUME_NONNULL_END