diff --git a/objective-c/auth_sample/SecondViewController.h b/objective-c/auth_sample/SecondViewController.h index 06a3ca012a8..3e5ccf95a44 100644 --- a/objective-c/auth_sample/SecondViewController.h +++ b/objective-c/auth_sample/SecondViewController.h @@ -33,6 +33,7 @@ #import -@interface SecondViewController : UIViewController +extern NSString * const kTestScope; +@interface SecondViewController : UIViewController @end diff --git a/objective-c/auth_sample/SecondViewController.m b/objective-c/auth_sample/SecondViewController.m index aa9e5b673e1..d5ba19a7aba 100644 --- a/objective-c/auth_sample/SecondViewController.m +++ b/objective-c/auth_sample/SecondViewController.m @@ -33,6 +33,10 @@ #import "SecondViewController.h" +#import + +NSString * const kTestScope = @"https://www.googleapis.com/auth/xapi.zoo"; + @implementation SecondViewController - (void)viewDidLoad { diff --git a/objective-c/auth_sample/SelectUserViewController.m b/objective-c/auth_sample/SelectUserViewController.m index 5e030565ef6..e54e9f866a5 100644 --- a/objective-c/auth_sample/SelectUserViewController.m +++ b/objective-c/auth_sample/SelectUserViewController.m @@ -33,6 +33,8 @@ #import "SelectUserViewController.h" +#import "SecondViewController.h" + @implementation SelectUserViewController - (void)viewDidLoad { @@ -42,10 +44,16 @@ self.signOutButton.hidden = YES; // As instructed in https://developers.google.com/identity/sign-in/ios/sign-in - GIDSignIn.sharedInstance.delegate = self; - GIDSignIn.sharedInstance.uiDelegate = self; + GIDSignIn *signIn = GIDSignIn.sharedInstance; + signIn.delegate = self; + signIn.uiDelegate = self; + + // As instructed in https://developers.google.com/identity/sign-in/ios/additional-scopes + if (![signIn.scopes containsObject:kTestScope]) { + signIn.scopes = [signIn.scopes arrayByAddingObject:kTestScope]; + } - [GIDSignIn.sharedInstance signInSilently]; + [signIn signInSilently]; } - (void)signIn:(GIDSignIn *)signIn @@ -67,8 +75,10 @@ didSignInForUser:(GIDGoogleUser *)user - (IBAction)didTapSignOut { [GIDSignIn.sharedInstance signOut]; + self.mainLabel.text = @"Please sign in."; self.subLabel.text = @""; + self.signInButton.hidden = NO; self.signOutButton.hidden = YES; }