GIDSignInInternalOptions.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Copyright 2021 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 <Foundation/Foundation.h>
  17. #if __has_include(<UIKit/UIKit.h>)
  18. #import <UIKit/UIKit.h>
  19. #elif __has_include(<AppKit/AppKit.h>)
  20. #import <AppKit/AppKit.h>
  21. #endif
  22. @class GIDConfiguration;
  23. @class GIDUserAuth;
  24. NS_ASSUME_NONNULL_BEGIN
  25. /// The options used internally for aspects of the sign-in flow.
  26. @interface GIDSignInInternalOptions : NSObject
  27. /// Whether interaction with user is allowed at all.
  28. @property(nonatomic, readonly) BOOL interactive;
  29. /// Whether the sign-in is a continuation of the previous one.
  30. @property(nonatomic, readonly) BOOL continuation;
  31. /// Whether the sign-in is an addScopes flow. NO means it is a sign in flow.
  32. @property(nonatomic, readonly) BOOL addScopesFlow;
  33. /// The extra parameters used in the sign-in URL.
  34. @property(nonatomic, readonly, nullable) NSDictionary *extraParams;
  35. /// The configuration to use during the flow.
  36. @property(nonatomic, readonly, nullable) GIDConfiguration *configuration;
  37. #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
  38. /// The view controller to use during the flow.
  39. @property(nonatomic, readonly, weak, nullable) UIViewController *presentingViewController;
  40. #elif TARGET_OS_OSX
  41. /// The window to use during the flow.
  42. @property(nonatomic, readonly, weak, nullable) NSWindow *presentingWindow;
  43. #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
  44. /// The completion block to be called at the completion of the flow.
  45. @property(nonatomic, readonly, nullable) void (^completion)(GIDUserAuth *_Nullable userAuth,
  46. NSError *_Nullable error);
  47. /// The scopes to be used during the flow.
  48. @property(nonatomic, copy, nullable) NSArray<NSString *> *scopes;
  49. /// The login hint to be used during the flow.
  50. @property(nonatomic, copy, nullable) NSString *loginHint;
  51. /// Creates the default options.
  52. #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
  53. + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
  54. presentingViewController:(nullable UIViewController *)presentingViewController
  55. loginHint:(nullable NSString *)loginHint
  56. addScopesFlow:(BOOL)addScopesFlow
  57. completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
  58. NSError *_Nullable error))completion;
  59. + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
  60. presentingViewController:(nullable UIViewController *)presentingViewController
  61. loginHint:(nullable NSString *)loginHint
  62. addScopesFlow:(BOOL)addScopesFlow
  63. scopes:(nullable NSArray *)scopes
  64. completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
  65. NSError *_Nullable error))completion;
  66. #elif TARGET_OS_OSX
  67. + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
  68. presentingWindow:(nullable NSWindow *)presentingWindow
  69. loginHint:(nullable NSString *)loginHint
  70. addScopesFlow:(BOOL)addScopesFlow
  71. completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
  72. NSError *_Nullable error))completion;
  73. + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
  74. presentingWindow:(nullable NSWindow *)presentingWindow
  75. loginHint:(nullable NSString *)loginHint
  76. addScopesFlow:(BOOL)addScopesFlow
  77. scopes:(nullable NSArray *)scopes
  78. completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
  79. NSError *_Nullable error))completion;
  80. #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
  81. /// Creates the options to sign in silently.
  82. + (instancetype)silentOptionsWithCompletion:(void (^)(GIDUserAuth *_Nullable userAuth,
  83. NSError *_Nullable error))completion;
  84. /// Creates options with the same values as the receiver, except for the "extra parameters", and
  85. /// continuation flag, which are replaced by the arguments passed to this method.
  86. - (instancetype)optionsWithExtraParameters:(NSDictionary *)extraParams
  87. forContinuation:(BOOL)continuation;
  88. @end
  89. NS_ASSUME_NONNULL_END