CreateAuthURIResponse.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. /// Represents the parameters for the createAuthUri endpoint.
  16. /// See https: // developers.google.com/identity/toolkit/web/reference/relyingparty/createAuthUri
  17. struct CreateAuthURIResponse: AuthRPCResponse {
  18. /// The URI used by the IDP to authenticate the user.
  19. var authURI: String?
  20. /// Whether the user is registered if the identifier is an email.
  21. var registered: Bool = false
  22. /// The provider ID of the auth URI.
  23. var providerID: String?
  24. /// True if the authUri is for user's existing provider.
  25. var forExistingProvider: Bool = false
  26. /// A list of provider IDs the passed identifier could use to sign in with.
  27. var allProviders: [String]?
  28. /// A list of sign-in methods available for the passed identifier.
  29. var signinMethods: [String] = []
  30. init(dictionary: [String: AnyHashable]) throws {
  31. providerID = dictionary["providerId"] as? String
  32. authURI = dictionary["authUri"] as? String
  33. registered = dictionary["registered"] as? Bool ?? false
  34. forExistingProvider = dictionary["forExistingProvider"] as? Bool ?? false
  35. allProviders = dictionary["allProviders"] as? [String]
  36. signinMethods = dictionary["signinMethods"] as? [String] ?? []
  37. }
  38. }