GetAccountInfoRequest.swift 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2023 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. import Foundation
  15. /** @var kGetAccountInfoEndpoint
  16. @brief The "getAccountInfo" endpoint.
  17. */
  18. private let kGetAccountInfoEndpoint = "getAccountInfo"
  19. /** @var kIDTokenKey
  20. @brief The key for the "idToken" value in the request. This is actually the STS Access Token,
  21. despite it's confusing (backwards compatiable) parameter name.
  22. */
  23. private let kIDTokenKey = "idToken"
  24. /** @class FIRGetAccountInfoRequest
  25. @brief Represents the parameters for the getAccountInfo endpoint.
  26. @see https://developers.google.com/identity/toolkit/web/reference/relyingparty/getAccountInfo
  27. */
  28. @available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
  29. class GetAccountInfoRequest: IdentityToolkitRequest, AuthRPCRequest {
  30. typealias Response = GetAccountInfoResponse
  31. /** @property accessToken
  32. @brief The STS Access Token for the authenticated user.
  33. */
  34. let accessToken: String
  35. /** @fn initWithAccessToken:requestConfiguration
  36. @brief Designated initializer.
  37. @param accessToken The Access Token of the authenticated user.
  38. @param requestConfiguration An object containing configurations to be added to the request.
  39. */
  40. init(accessToken: String, requestConfiguration: AuthRequestConfiguration) {
  41. self.accessToken = accessToken
  42. super.init(endpoint: kGetAccountInfoEndpoint, requestConfiguration: requestConfiguration)
  43. }
  44. func unencodedHTTPRequestBody() throws -> [String: AnyHashable] {
  45. return [kIDTokenKey: accessToken]
  46. }
  47. }