Просмотр исходного кода

Implement default options creation methods.

brianna 1 год назад
Родитель
Сommit
94a4175aaf

+ 0 - 1
GoogleSignIn/Sources/GIDSignInInternalOptions.m

@@ -36,7 +36,6 @@ NS_ASSUME_NONNULL_BEGIN
   GIDSignInInternalOptions *options = [[GIDSignInInternalOptions alloc] init];
   if (options) {
     options->_interactive = YES;
-    options->_continuation = NO;
     options->_addScopesFlow = addScopesFlow;
     options->_configuration = configuration;
     options->_presentingViewController = presentingViewController;

+ 20 - 58
GoogleSignIn/Sources/GIDVerifyAccountDetail/Implementations/GIDVerifyAccountDetail.m

@@ -31,7 +31,10 @@
     presentingViewController:(UIViewController *)presentingViewController
                   completion:(nullable void (^)(GIDVerifiedAccountDetailResult *_Nullable verifyResult,
                                                 NSError *_Nullable error))completion {
-  // TODO(#383): Implement this method.
+  [self verifyAccountDetails:accountDetails
+    presentingViewController:presentingViewController
+                        hint:nil
+                  completion:completion];
 }
 
 - (void)verifyAccountDetails:(NSArray<GIDVerifiableAccountDetail *> *)accountDetails
@@ -39,69 +42,28 @@
                         hint:(nullable NSString *)hint
                   completion:(nullable void (^)(GIDVerifiedAccountDetailResult *_Nullable verifyResult,
                                                 NSError *_Nullable error))completion {
-  // TODO(#383): Implement this method.
-}
+  // Get the bundle of the current executable.
+  NSBundle *bundle = NSBundle.mainBundle;
 
-- (void)verifyAccountDetails:(NSArray<GIDVerifiableAccountDetail *> *)accountDetails
-    presentingViewController:(UIViewController *)presentingViewController
-                        hint:(nullable NSString *)hint
-            additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
-                  completion:(nullable void (^)(GIDVerifiedAccountDetailResult *_Nullable verifyResult,
-                                                NSError *_Nullable error))completion {
-  // TODO(#383): Implement this method.
-}
-
-// Starts authorization flow using the provided options.
-- (void)verifyAccountDetailsInteractivelyWithOptions:(GIDSignInInternalOptions *)options {
-  if (!options.interactive) {
-    return;
-  }
-  
-  // Ensure that a configuration is set.
-  if (!_configuration) {
-    // NOLINTNEXTLINE(google-objc-avoid-throwing-exception)
-    [NSException raise:NSInvalidArgumentException
-                format:@"No active configuration. Make sure GIDClientID is set in Info.plist."];
-    return;    
+  // If we have a bundle, try to set the active configuration from the bundle's Info.plist.
+  if (bundle) {
+    _configuration = [GIDConfiguration configurationFromBundle:bundle];
   }
-  
-  // Explicitly throw exception for missing client ID here. This must come before
-  // scheme check because schemes rely on reverse client IDs.
-  [self assertValidParameters:options];
-  
-  [self assertValidPresentingViewController:options];
-  
-  // If the application does not support the required URL schemes tell the developer so.
-  GIDSignInCallbackSchemes *schemes =
-  [[GIDSignInCallbackSchemes alloc] initWithClientIdentifier:options.configuration.clientID];
-  NSArray<NSString *> *unsupportedSchemes = [schemes unsupportedSchemes];
-  if (unsupportedSchemes.count != 0) {
-    // NOLINTNEXTLINE(google-objc-avoid-throwing-exception)
-    [NSException raise:NSInvalidArgumentException
-                format:@"Your app is missing support for the following URL schemes: %@",
-     [unsupportedSchemes componentsJoinedByString:@", "]];
-  }
-  // TODO(#397): Start the incremental authorization flow.
-}
 
-#pragma mark - Helpers
+  GIDSignInInternalOptions *options =
+  [GIDSignInInternalOptions defaultOptionsWithConfiguration:_configuration
+                                   presentingViewController:presentingViewController
+                                                  loginHint:hint
+                                              addScopesFlow:YES
+                                     accountDetailsToVerify:accountDetails
+                                           verifyCompletion:completion];
 
-// Asserts the parameters being valid.
-- (void)assertValidParameters:(GIDSignInInternalOptions *)options {
-  if (![options.configuration.clientID length]) {
-    // NOLINTNEXTLINE(google-objc-avoid-throwing-exception)
-    [NSException raise:NSInvalidArgumentException
-                format:@"You must specify |clientID| in |GIDConfiguration|"];
-  }
+  [self verifyAccountDetailsInteractivelyWithOptions:options];
 }
 
-// Assert that the presenting view controller has been set.
-- (void)assertValidPresentingViewController:(GIDSignInInternalOptions *)options {
-  if (!options.presentingViewController) {
-    // NOLINTNEXTLINE(google-objc-avoid-throwing-exception)
-    [NSException raise:NSInvalidArgumentException
-                format:@"|presentingViewController| must be set."];
-  }
+// Starts authorization flow using the provided options.
+- (void)verifyAccountDetailsInteractivelyWithOptions:(GIDSignInInternalOptions *)options {
+  // TODO(#397): Sanity checks and start the incremental authorization flow.
 }
 
 @end

+ 0 - 18
GoogleSignIn/Sources/Public/GoogleSignIn/GIDVerifyAccountDetail.h

@@ -72,24 +72,6 @@ typedef void (^GIDVerifyCompletion)(GIDVerifiedAccountDetailResult *_Nullable ve
                   completion:(nullable void (^)(GIDVerifiedAccountDetailResult *_Nullable verifyResult,
                                                 NSError *_Nullable error))completion;
 
-/// Starts an interactive verification flow using the provided hint and additional scopes.
-///
-/// The completion will be called at the end of this process.  Any saved verification
-/// state will be replaced by the result of this flow.
-///
-/// @param accountDetails A list of verifiable account details.
-/// @param presentingViewController The view controller used to present the flow.
-/// @param hint An optional hint for the authorization server, for example the user's ID or email
-///     address, to be prefilled if possible.
-/// @param additionalScopes An optional array of scopes to request in addition to the basic profile scopes.
-/// @param completion The optional block called asynchronously on the main queue upon completion.
-- (void)verifyAccountDetails:(NSArray<GIDVerifiableAccountDetail *> *)accountDetails
-    presentingViewController:(UIViewController *)presentingViewController
-                        hint:(nullable NSString *)hint
-            additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
-                  completion:(nullable void (^)(GIDVerifiedAccountDetailResult *_Nullable verifyResult,
-                                                NSError *_Nullable error))completion;
-
 @end
 
 NS_ASSUME_NONNULL_END