|
|
@@ -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
|