GetAccountInfoRequest.swift 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. /// The "getAccountInfo" endpoint.
  16. private let kGetAccountInfoEndpoint = "getAccountInfo"
  17. /// The key for the "idToken" value in the request. This is actually the STS Access Token,
  18. /// despite its confusing (backwards compatible) parameter name.
  19. private let kIDTokenKey = "idToken"
  20. /// Represents the parameters for the getAccountInfo endpoint.
  21. /// See https://developers.google.com/identity/toolkit/web/reference/relyingparty/getAccountInfo
  22. @available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
  23. class GetAccountInfoRequest: IdentityToolkitRequest, AuthRPCRequest,
  24. @unchecked Sendable /* TODO: sendable */ {
  25. typealias Response = GetAccountInfoResponse
  26. /// The STS Access Token for the authenticated user.
  27. let accessToken: String
  28. /// Designated initializer.
  29. /// - Parameter accessToken: The Access Token of the authenticated user.
  30. /// - Parameter requestConfiguration: An object containing configurations to be added to the
  31. /// request.
  32. init(accessToken: String, requestConfiguration: AuthRequestConfiguration) {
  33. self.accessToken = accessToken
  34. super.init(endpoint: kGetAccountInfoEndpoint, requestConfiguration: requestConfiguration)
  35. }
  36. var unencodedHTTPRequestBody: [String: AnyHashable]? {
  37. return [kIDTokenKey: accessToken]
  38. }
  39. }