浏览代码

Merge branch 'main' into refactorGSI

pinlu 3 年之前
父节点
当前提交
19d4c2ca48

+ 58 - 31
CHANGELOG.md

@@ -1,24 +1,51 @@
-# 6.2.4 (2022-9-13)
+# 7.0.0
+- All configuration can now be provided via your `Info.plist` file. ([#228](https://github.com/google/GoogleSignIn-iOS/pull/228))
+  - Use the following keys in `<key>KEY</key><string>VALUE</string>` pairs to configure the SDK:
+    - `GIDClientID` (required)
+    - `GIDServerClientID` (optional)
+    - `GIDHostedDomain` (optional)
+    - `GIDOpenIDRealm` (optional)
+- Support for [Swift Concurrency](https://docs.swift.org/swift-book/LanguageGuide/Concurrency.html). ([#187](https://github.com/google/GoogleSignIn-iOS/pull/187))
+- API surface improvements ([#249](https://github.com/google/GoogleSignIn-iOS/pull/249), [#228](https://github.com/google/GoogleSignIn-iOS/pull/228), [#187](https://github.com/google/GoogleSignIn-iOS/pull/187))
+  - `GIDSignIn`
+    - New `configuration` property.
+    - Removed `Configuration:` arguments from `signIn:` methods.
+    - Removed `addScopes:` and added it to `GIDGoogleUser`.
+    - Renamed `callback:` arguments to `completion:` for asynchronous methods taking blocks.
+  - `GIDGoogleUser`
+    - New `configuration` property.
+    - New `addScopes:` method moved from `GIDSignIn`.
+    - Removed `authentication` property and replaced it with:
+      - New `accessToken` property.
+      - New `refreshToken` property.
+      - New `idToken` property.
+      - New `fetcherAuthorizer` property.
+      - New `refreshTokensIfNeededWithCompletion:` method.
+  - New `GIDToken` class to represent access, refresh, and ID tokens in `GIDGoogleUser`.
+  - New `GIDSignInResult` class to represent the result of a successful signIn or addScopes flow.
+  - Removed `GIDSignInCallback`, `GIDDisconnectCallback`, and `GIDAuthenticationAction` block type definitions.
+
+# 6.2.4
 - Updated the GTMSessionFetcher dependency to allow 2.x versions. ([#207](https://github.com/google/GoogleSignIn-iOS/pull/207))
 
-# 6.2.3 (2022-8-18)
+# 6.2.3
 - Fix resource loading in GoogleSignInSwift with CocoaPods use_frameworks! ([#197](https://github.com/google/GoogleSignIn-iOS/pull/197))
 - Prevent build errors for GoogleSignInSwift in certain scenarios when using Swift Package Manager. ([#166](https://github.com/google/GoogleSignIn-iOS/pull/166))
 
-# 6.2.2 (2022-5-27)
+# 6.2.2
 - Prevent build errors for GoogleSignInSwift when using Swift Package Manager. ([#157](https://github.com/google/GoogleSignIn-iOS/pull/157))
 - Prevent a build error on Xcode 12 and earlier. ([#158](https://github.com/google/GoogleSignIn-iOS/pull/158))
 
-# 6.2.1 (2022-5-19)
+# 6.2.1
 - Use `GoogleSignInSwiftSupport` as the name of the Swift support CocoaPod. ([#137](https://github.com/google/GoogleSignIn-iOS/pull/137))
 
-# 6.2.0 (2022-5-18)
+# 6.2.0
 - Support for macOS. ([#104](https://github.com/google/GoogleSignIn-iOS/pull/104))
 - Added a SwiftUI "Sign in with Google" button. ([#103](https://github.com/google/GoogleSignIn-iOS/pull/103))
 - Added the ability to request additional scopes at sign-in time. ([#30](https://github.com/google/GoogleSignIn-iOS/pull/30))
 - Fixed several issues. ([#87](https://github.com/google/GoogleSignIn-iOS/pull/87), [#106](https://github.com/google/GoogleSignIn-iOS/issues/106))
 
-# 6.1.0 (2021-12-16)
+# 6.1.0
 - New Swift sample app demonstrating SwiftUI.
   ([#63](https://github.com/google/GoogleSignIn-iOS/pull/63))
 - Support for Mac Catalyst.
@@ -26,15 +53,15 @@
   ([#68](https://github.com/google/GoogleSignIn-iOS/pull/68),
   [#70](https://github.com/google/GoogleSignIn-iOS/pull/70))
 
-# 6.0.2 (2021-8-20)
+# 6.0.2
 - Ensure that module imports can be used when built as a library.
   ([#53](https://github.com/google/GoogleSignIn-iOS/pull/53))
 
-# 6.0.1 (2021-7-21)
+# 6.0.1
 - Fixes nested callbacks not being called for signIn and addScopes methods.
   ([#29](https://github.com/google/GoogleSignIn-iOS/pull/29))
 
-# 6.0.0 (2021-7-13)
+# 6.0.0
 - Google Sign-In for iOS is now open source.
 - Swift Package Manager support.
 - Support for Simulator on M1 Macs.
@@ -60,15 +87,15 @@
     an `IBAction` or similar in order for you to call
     `signInWithConfiguration:presentingViewController:callback:` to initiate a sign-in flow.
 
-# 5.0.2 (2019-11-7)
+# 5.0.2
 - Fixes the wrong error code being sent to `signIn:didSignInForUser:withError:` when the user
   cancels iOS's consent dialog during the sign-in flow.
 
-# 5.0.1 (2019-10-9)
+# 5.0.1
 - Fixes an issue that the sign in flow cannot be correctly started on iOS 13.
 - The zip distribution requires Xcode 11 or above.
 
-# 5.0.0 (2019-8-14)
+# 5.0.0
 - Changes to GIDSignIn
   - `uiDelegate` has been replaced with `presentingViewController`.
   - `hasAuthInKeychain` has been replaced with `hasPreviousSignIn`.
@@ -82,40 +109,40 @@
 - Removes the dependency on GoogleToolboxForMac.
 - Drops support for iOS 7.
 
-# 4.4.0 (2018-11-26)
+# 4.4.0
 - Removes the dependency on GTM OAuth 2.
 
-# 4.3.0 (2018-10-1)
+# 4.3.0
 - Supports Google's Enterprise Mobile Management.
 
-# 4.2.0 (2018-8-10)
+# 4.2.0
 - Adds `grantedScopes` to `GIDGoogleUser`, allowing confirmation of which scopes
   have been granted after a successful sign-in.
 - Deprecates `accessibleScopes` in `GIDGoogleUser`, use `grantedScopes` instead.
 - Localizes `GIDSignInButton` for hi (Hindi) and fr-CA (French (Canada)).
 - Adds dependency to the system `LocalAuthentication` framework.
 
-# 4.1.2 (2018-1-8)
+# 4.1.2
 - Add `pod try` support for the GoogleSignIn CocoaPod.
 
-# 4.1.1 (2017-10-17)
+# 4.1.1
 - Fixes an issue that `GIDSignInUIDelegate`'s `signInWillDispatch:error:` was
   not called on iOS 11. Please note that it is intended that neither
   `signIn:presentViewController:` nor `signIn:dismissViewController:` is called
   on iOS 11 because SFAuthenticationSession is not presented by the app's view
   controller.
 
-# 4.1.0 (2017-09-13)
+# 4.1.0
 - Uses SFAuthenticationSession on iOS 11.
 
-# 4.0.2 (2017-2-6)
+# 4.0.2
 - No longer depends on GoogleAppUtilities.
 
-# 4.0.1 (2016-10-24)
+# 4.0.1
 - Switches to open source pod dependencies.
 - Appearance of sign-in button no longer depends on requested scopes.
 
-# 4.0.0 (2016-4-21)
+# 4.0.0
 - GoogleSignIn pod now takes form of a static framework. Import with
   `#import <GoogleSignIn/GoogleSignIn.h>` in Objective-C.
 - Adds module support. You can also use `@import GoogleSignIn;` in Objective-C,
@@ -129,7 +156,7 @@
   from `GIDSignIn`.
 - No longer requires adding bundle ID as a URL scheme supported by the app.
 
-# 3.0.0 (2016-3-4)
+# 3.0.0
 - Provides `givenName` and `familyName` properties on `GIDProfileData`.
 - Allows setting the `loginHint` property on `GIDSignIn` to prefill the user's
   ID or email address in the sign-in flow.
@@ -141,41 +168,41 @@
 - Provides bitcode support.
 - Requires Xcode 7.0 or above due to bitcode incompatibilities with Xcode 6.
 
-# 2.4.0 (2015-10-26)
+# 2.4.0
 - Updates sign-in button with the new Google logo.
 - Supports domain restriction for sign-in.
 - Allows refreshing ID tokens.
 
-# 2.3.2 (2015-10-9)
+# 2.3.2
 - No longer requires Xcode 7.
 
-# 2.3.1 (2015-10-1)
+# 2.3.1
 - Fixes a crash in `GIDProfileData`'s `imageURLWithDimension:`.
 
-# 2.3.0 (2015-9-25)
+# 2.3.0
 - Requires Xcode 7.0 or above.
 - Uses SFSafariViewController for signing in on iOS 9.  `uiDelegate` must be
   set for this to work.
 - Optimizes fetching user profile.
 - Supports GTMFetcherAuthorizationProtocol in GIDAuthentication.
 
-# 2.2.0 (2015-7-15)
+# 2.2.0
 - Compatible with iOS 9 (beta).  Note that this version of the Sign-In SDK does
   not include bitcode, so you must set ENABLE_BITCODE to NO in your project if
   you use Xcode 7.
 - Adds descriptive identifiers for GIDSignInButton's Auto Layout constraints.
 - `signInSilently` no longer requires setting `uiDelegate`.
 
-# 2.1.0 (2015-6-17)
+# 2.1.0
 - Fixes Auto Layout issues with GIDSignInButton.
 - Adds API to refresh access token in GIDAuthentication.
 - Better exception description for unassigned clientID in GIDSignIn.
 - Other minor bug fixes.
 
-# 2.0.1 (2015-5-28)
+# 2.0.1
 - Bug fixes
 
-# 2.0.0 (2015-5-21)
+# 2.0.0
 - Supports sign-in via UIWebView rather than app switching to a browser,
   configurable with the new `allowsSignInWithWebView` property.
 - Now apps which have disabled the app switch to a browser via the
@@ -187,7 +214,7 @@
   is `NO` as documented
 - Other minor bug fixes
 
-# 1.0.0 (2015-3-12)
+# 1.0.0
 - New sign-in focused SDK with refreshed API
 - Dynamically rendered sign-in button with contextual branding
 - Basic profile support

+ 1 - 1
GoogleSignIn/Sources/GIDGoogleUser.m

@@ -189,7 +189,7 @@ static NSTimeInterval const kMinimalTimeToExpire = 60.0;
 #elif TARGET_OS_OSX
             presentingWindow:(NSWindow *)presentingWindow
 #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
-                  completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
+                  completion:(nullable void (^)(GIDSignInResult *_Nullable signInResult,
                                                 NSError *_Nullable error))completion {
   if (self != GIDSignIn.sharedInstance.currentUser) {
     NSError *error = [NSError errorWithDomain:kGIDSignInErrorDomain

+ 21 - 19
GoogleSignIn/Sources/GIDSignIn.m

@@ -19,7 +19,7 @@
 #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDConfiguration.h"
 #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDGoogleUser.h"
 #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDProfileData.h"
-#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDUserAuth.h"
+#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignInResult.h"
 
 #import "GoogleSignIn/Sources/GIDEMMSupport.h"
 #import "GoogleSignIn/Sources/GIDKeychainHandler/API/GIDKeychainHandler.h"
@@ -36,7 +36,7 @@
 
 #import "GoogleSignIn/Sources/GIDGoogleUser_Private.h"
 #import "GoogleSignIn/Sources/GIDProfileData_Private.h"
-#import "GoogleSignIn/Sources/GIDUserAuth_Private.h"
+#import "GoogleSignIn/Sources/GIDSignInResult_Private.h"
 
 #ifdef SWIFT_PACKAGE
 @import AppAuth;
@@ -205,9 +205,9 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
 - (void)restorePreviousSignInWithCompletion:(nullable void (^)(GIDGoogleUser *_Nullable user,
                                                                NSError *_Nullable error))completion {
   [self signInWithOptions:[GIDSignInInternalOptions silentOptionsWithCompletion:
-                           ^(GIDUserAuth *userAuth, NSError *error) {
-    if (userAuth) {
-      completion(userAuth.user, nil);
+                           ^(GIDSignInResult *signInResult, NSError *error) {
+    if (signInResult) {
+      completion(signInResult.user, nil);
     } else {
       completion(nil, error);
     }
@@ -239,7 +239,7 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
 
 - (void)signInWithPresentingViewController:(UIViewController *)presentingViewController
                                       hint:(nullable NSString *)hint
-                                completion:(nullable GIDUserAuthCompletion)completion {
+                                completion:(nullable GIDSignInCompletion)completion {
   GIDSignInInternalOptions *options =
       [GIDSignInInternalOptions defaultOptionsWithConfiguration:_configuration
                                        presentingViewController:presentingViewController
@@ -252,7 +252,7 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
 - (void)signInWithPresentingViewController:(UIViewController *)presentingViewController
                                       hint:(nullable NSString *)hint
                           additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
-                                completion:(nullable GIDUserAuthCompletion)completion {
+                                completion:(nullable GIDSignInCompletion)completion {
   GIDSignInInternalOptions *options =
     [GIDSignInInternalOptions defaultOptionsWithConfiguration:_configuration
                                      presentingViewController:presentingViewController
@@ -264,7 +264,7 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
 }
 
 - (void)signInWithPresentingViewController:(UIViewController *)presentingViewController
-                                completion:(nullable GIDUserAuthCompletion)completion {
+                                completion:(nullable GIDSignInCompletion)completion {
   [self signInWithPresentingViewController:presentingViewController
                                       hint:nil
                                 completion:completion];
@@ -272,7 +272,7 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
 
 - (void)addScopes:(NSArray<NSString *> *)scopes
     presentingViewController:(UIViewController *)presentingViewController
-                  completion:(nullable GIDUserAuthCompletion)completion {
+                  completion:(nullable GIDSignInCompletion)completion {
   GIDConfiguration *configuration = self.currentUser.configuration;
   GIDSignInInternalOptions *options =
       [GIDSignInInternalOptions defaultOptionsWithConfiguration:configuration
@@ -310,7 +310,7 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
 
 - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
                               hint:(nullable NSString *)hint
-                        completion:(nullable GIDUserAuthCompletion)completion {
+                        completion:(nullable GIDSignInCompletion)completion {
   GIDSignInInternalOptions *options =
       [GIDSignInInternalOptions defaultOptionsWithConfiguration:_configuration
                                                presentingWindow:presentingWindow
@@ -321,7 +321,7 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
 }
 
 - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
-                        completion:(nullable GIDUserAuthCompletion)completion {
+                        completion:(nullable GIDSignInCompletion)completion {
   [self signInWithPresentingWindow:presentingWindow
                               hint:nil
                         completion:completion];
@@ -330,7 +330,7 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
 - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
                               hint:(nullable NSString *)hint
                   additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
-                        completion:(nullable GIDUserAuthCompletion)completion {
+                        completion:(nullable GIDSignInCompletion)completion {
   GIDSignInInternalOptions *options =
     [GIDSignInInternalOptions defaultOptionsWithConfiguration:_configuration
                                              presentingWindow:presentingWindow
@@ -343,7 +343,7 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
 
 - (void)addScopes:(NSArray<NSString *> *)scopes
  presentingWindow:(NSWindow *)presentingWindow
-       completion:(nullable GIDUserAuthCompletion)completion {
+       completion:(nullable GIDSignInCompletion)completion {
   GIDConfiguration *configuration = self.currentUser.configuration;
   GIDSignInInternalOptions *options =
       [GIDSignInInternalOptions defaultOptionsWithConfiguration:configuration
@@ -540,8 +540,9 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
         if (options.completion) {
           self->_currentOptions = nil;
           dispatch_async(dispatch_get_main_queue(), ^{
-            GIDUserAuth *userAuth = [[GIDUserAuth alloc] initWithGoogleUser:self->_currentUser serverAuthCode:nil];
-            options.completion(userAuth, nil);
+            GIDSignInResult *signInResult =
+                [[GIDSignInResult alloc] initWithGoogleUser:self->_currentUser serverAuthCode:nil];
+            options.completion(signInResult, nil);
           });
         }
       }
@@ -854,7 +855,7 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
   [authFlow addCallback:^() {
     GIDAuthFlow *handlerAuthFlow = weakAuthFlow;
     if (self->_currentOptions.completion) {
-      GIDUserAuthCompletion completion = self->_currentOptions.completion;
+      GIDSignInCompletion completion = self->_currentOptions.completion;
       self->_currentOptions = nil;
       dispatch_async(dispatch_get_main_queue(), ^{
         if (handlerAuthFlow.error) {
@@ -863,9 +864,10 @@ static NSString *const kConfigOpenIDRealmKey = @"GIDOpenIDRealm";
           OIDAuthState *authState = handlerAuthFlow.authState;
           NSString *_Nullable serverAuthCode =
               [authState.lastTokenResponse.additionalParameters[@"server_code"] copy];
-          GIDUserAuth *userAuth = [[GIDUserAuth alloc] initWithGoogleUser:self->_currentUser
-                                                           serverAuthCode:serverAuthCode];
-          completion(userAuth, nil);
+          GIDSignInResult *signInResult =
+              [[GIDSignInResult alloc] initWithGoogleUser:self->_currentUser
+                                           serverAuthCode:serverAuthCode];
+          completion(signInResult, nil);
         }
       });
     }

+ 9 - 13
GoogleSignIn/Sources/GIDSignInInternalOptions.h

@@ -22,8 +22,10 @@
 #import <AppKit/AppKit.h>
 #endif
 
+#import "GoogleSignIn/Sources/GIDSignIn_Private.h"
+
 @class GIDConfiguration;
-@class GIDUserAuth;
+@class GIDSignInResult;
 
 NS_ASSUME_NONNULL_BEGIN
 
@@ -54,8 +56,7 @@ NS_ASSUME_NONNULL_BEGIN
 #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
 
 /// The completion block to be called at the completion of the flow.
-@property(nonatomic, readonly, nullable) void (^completion)(GIDUserAuth *_Nullable userAuth,
-                                                            NSError *_Nullable error);
+@property(nonatomic, readonly, nullable) GIDSignInCompletion completion;
 
 /// The scopes to be used during the flow.
 @property(nonatomic, copy, nullable) NSArray<NSString *> *scopes;
@@ -69,37 +70,32 @@ NS_ASSUME_NONNULL_BEGIN
                        presentingViewController:(nullable UIViewController *)presentingViewController
                                       loginHint:(nullable NSString *)loginHint
                                   addScopesFlow:(BOOL)addScopesFlow
-                                     completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
-                                                                   NSError *_Nullable error))completion;
+                                     completion:(nullable GIDSignInCompletion)completion;
 
 + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
                        presentingViewController:(nullable UIViewController *)presentingViewController
                                       loginHint:(nullable NSString *)loginHint
                                   addScopesFlow:(BOOL)addScopesFlow
                                          scopes:(nullable NSArray *)scopes
-                                     completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
-                                                                   NSError *_Nullable error))completion;
+                                     completion:(nullable GIDSignInCompletion)completion;
 
 #elif TARGET_OS_OSX
 + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
                                presentingWindow:(nullable NSWindow *)presentingWindow
                                       loginHint:(nullable NSString *)loginHint
                                   addScopesFlow:(BOOL)addScopesFlow
-                                     completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
-                                                                   NSError *_Nullable error))completion;
+                                     completion:(nullable GIDSignInCompletion)completion;
 
 + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
                                presentingWindow:(nullable NSWindow *)presentingWindow
                                       loginHint:(nullable NSString *)loginHint
                                   addScopesFlow:(BOOL)addScopesFlow
                                          scopes:(nullable NSArray *)scopes
-                                     completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
-                                                                   NSError *_Nullable error))completion;
+                                     completion:(nullable GIDSignInCompletion)completion;
 #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
 
 /// Creates the options to sign in silently.
-+ (instancetype)silentOptionsWithCompletion:(void (^)(GIDUserAuth *_Nullable userAuth,
-                                                      NSError *_Nullable error))completion;
++ (instancetype)silentOptionsWithCompletion:(GIDSignInCompletion)completion;
 
 /// Creates options with the same values as the receiver, except for the "extra parameters", and
 /// continuation flag, which are replaced by the arguments passed to this method.

+ 5 - 10
GoogleSignIn/Sources/GIDSignInInternalOptions.m

@@ -31,16 +31,14 @@ NS_ASSUME_NONNULL_BEGIN
                                       loginHint:(nullable NSString *)loginHint
                                   addScopesFlow:(BOOL)addScopesFlow
                                          scopes:(nullable NSArray *)scopes
-                                     completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
-                                                                   NSError *_Nullable error))completion {
+                                     completion:(nullable GIDSignInCompletion)completion {
 #elif TARGET_OS_OSX
 + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
                                presentingWindow:(nullable NSWindow *)presentingWindow
                                       loginHint:(nullable NSString *)loginHint
                                   addScopesFlow:(BOOL)addScopesFlow
                                          scopes:(nullable NSArray *)scopes
-                                     completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
-                                                                   NSError *_Nullable error))completion {
+                                     completion:(nullable GIDSignInCompletion)completion {
 #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
   GIDSignInInternalOptions *options = [[GIDSignInInternalOptions alloc] init];
   if (options) {
@@ -65,15 +63,13 @@ NS_ASSUME_NONNULL_BEGIN
                        presentingViewController:(nullable UIViewController *)presentingViewController
                                       loginHint:(nullable NSString *)loginHint
                                   addScopesFlow:(BOOL)addScopesFlow
-                                     completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
-                                                                   NSError *_Nullable error))completion {
+                                     completion:(nullable GIDSignInCompletion)completion {
 #elif TARGET_OS_OSX
 + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
                                presentingWindow:(nullable NSWindow *)presentingWindow
                                       loginHint:(nullable NSString *)loginHint
                                   addScopesFlow:(BOOL)addScopesFlow
-                                     completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
-                                                                   NSError *_Nullable error))completion {
+                                     completion:(nullable GIDSignInCompletion)completion {
 #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
     GIDSignInInternalOptions *options = [self defaultOptionsWithConfiguration:configuration
 #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
@@ -88,8 +84,7 @@ NS_ASSUME_NONNULL_BEGIN
   return options;
 }
 
-+ (instancetype)silentOptionsWithCompletion:(void (^)(GIDUserAuth *_Nullable userAuth,
-                                                      NSError *_Nullable error))completion {
++ (instancetype)silentOptionsWithCompletion:(GIDSignInCompletion)completion {
   GIDSignInInternalOptions *options = [self defaultOptionsWithConfiguration:nil
 #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
                                                    presentingViewController:nil

+ 4 - 4
GoogleSignIn/Sources/GIDUserAuth.m → GoogleSignIn/Sources/GIDSignInResult.m

@@ -1,5 +1,5 @@
 /*
- * Copyright 2021 Google LLC
+ * Copyright 2022 Google LLC
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,12 +14,12 @@
  * limitations under the License.
  */
 
-#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDUserAuth.h"
+#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignInResult.h"
 
-#import "GoogleSignIn/Sources/GIDUserAuth_Private.h"
+#import "GoogleSignIn/Sources/GIDSignInResult_Private.h"
 #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDGoogleUser.h"
 
-@implementation GIDUserAuth
+@implementation GIDSignInResult
 
 - (instancetype)initWithGoogleUser:(GIDGoogleUser *)user
                     serverAuthCode:(nullable NSString *)serverAuthCode {

+ 4 - 4
GoogleSignIn/Sources/GIDUserAuth_Private.h → GoogleSignIn/Sources/GIDSignInResult_Private.h

@@ -14,14 +14,14 @@
  * limitations under the License.
  */
 
-#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDUserAuth.h"
+#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignInResult.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
-// Private |GIDUserAuth| methods that are used in this SDK.
-@interface GIDUserAuth ()
+// Private |GIDSignInResult| methods that are used in this SDK.
+@interface GIDSignInResult ()
 
-// Private initializer for |GIDUserAuth|.
+// Private initializer for |GIDSignInResult|.
 // @param user The current GIDGoogleUser.
 // @param severAuthCode The one-time authorization code for backend to exchange
 //     access and refresh tokens.

+ 9 - 6
GoogleSignIn/Sources/GIDSignIn_Private.h

@@ -35,6 +35,11 @@ NS_ASSUME_NONNULL_BEGIN
 /// was unsuccessful.
 typedef void (^GIDUserAuthCompletion)(GIDUserAuth *_Nullable userAuth, NSError *_Nullable error);
 
+/// Represents a completion block that takes a `GIDSignInResult` on success or an error if the
+/// operation was unsuccessful.
+typedef void (^GIDSignInCompletion)(GIDSignInResult *_Nullable signInResult,
+                                    NSError *_Nullable error);
+
 /// Represents a completion block that takes an error if the operation was unsuccessful.
 typedef void (^GIDDisconnectCompletion)(NSError *_Nullable error);
 
@@ -66,7 +71,7 @@ typedef void (^GIDDisconnectCompletion)(NSError *_Nullable error);
 
 /// Starts an interactive consent flow on iOS to add scopes to the current user's grants.
 ///
-/// The completion will be called at the end of this process.  If successful, a `GIDUserAuth`
+/// The completion will be called at the end of this process.  If successful, a `GIDSignInResult`
 /// instance will be returned reflecting the new scopes and saved sign-in state will be updated.
 ///
 /// @param scopes The scopes to ask the user to consent to.
@@ -77,15 +82,14 @@ typedef void (^GIDDisconnectCompletion)(NSError *_Nullable error);
 ///     on the main queue.
 - (void)addScopes:(NSArray<NSString *> *)scopes
     presentingViewController:(UIViewController *)presentingViewController
-                  completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
-                                                NSError *_Nullable error))completion
+                  completion:(nullable GIDSignInCompletion)completion
     NS_EXTENSION_UNAVAILABLE("The add scopes flow is not supported in App Extensions.");
 
 #elif TARGET_OS_OSX
 
 /// Starts an interactive consent flow on macOS to add scopes to the current user's grants.
 ///
-/// The completion will be called at the end of this process.  If successful, a `GIDUserAuth`
+/// The completion will be called at the end of this process.  If successful, a `GIDSignInResult`
 /// instance will be returned reflecting the new scopes and saved sign-in state will be updated.
 ///
 /// @param scopes An array of scopes to ask the user to consent to.
@@ -95,8 +99,7 @@ typedef void (^GIDDisconnectCompletion)(NSError *_Nullable error);
 ///     on the main queue.
 - (void)addScopes:(NSArray<NSString *> *)scopes
     presentingWindow:(NSWindow *)presentingWindow
-          completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
-                                        NSError *_Nullable error))completion;
+          completion:(nullable GIDSignInCompletion)completion;
 
 #endif
 

+ 19 - 19
GoogleSignIn/Sources/Public/GoogleSignIn/GIDGoogleUser.h

@@ -32,22 +32,22 @@
 #endif
 
 @class GIDConfiguration;
-@class GIDUserAuth;
+@class GIDSignInResult;
 @class GIDToken;
 @class GIDProfileData;
 
 NS_ASSUME_NONNULL_BEGIN
 
-/// This class represents a user account.
+/// This class represents a signed-in user.
 @interface GIDGoogleUser : NSObject <NSSecureCoding>
 
 /// The Google user ID.
 @property(nonatomic, readonly, nullable) NSString *userID;
 
-/// Representation of basic profile data for the user.
+/// The basic profile data for the user.
 @property(nonatomic, readonly, nullable) GIDProfileData *profile;
 
-/// The API scopes granted to the app in an array of `NSString`.
+/// The OAuth2 scopes granted to the app in an array of `NSString`.
 @property(nonatomic, readonly, nullable) NSArray<NSString *> *grantedScopes;
 
 /// The configuration that was used to sign in this user.
@@ -59,20 +59,19 @@ NS_ASSUME_NONNULL_BEGIN
 /// The OAuth2 refresh token to exchange for new access tokens.
 @property(nonatomic, readonly) GIDToken *refreshToken;
 
-/// An OpenID Connect ID token that identifies the user.
+/// The OpenID Connect ID token that identifies the user.
 ///
 /// Send this token to your server to authenticate the user there. For more information on this topic,
 /// see https://developers.google.com/identity/sign-in/ios/backend-auth.
 @property(nonatomic, readonly, nullable) GIDToken *idToken;
 
-/// The authorizer for `GTLService`, `GTMSessionFetcher`, or `GTMHTTPFetcher`.
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
+/// The authorizer for use with `GTLRService`, `GTMSessionFetcher`, or `GTMHTTPFetcher`.
 @property(nonatomic, readonly) id<GTMFetcherAuthorizationProtocol> fetcherAuthorizer;
 #pragma clang diagnostic pop
 
-/// Get a valid access token and a valid ID token, refreshing them first if they have expired or
-/// are about to expire.
+/// Refresh the user's access and ID tokens if they have expired or are about to expire.
 ///
 /// @param completion A completion block that takes a `GIDGoogleUser` or an error if the attempt to
 ///     refresh tokens was unsuccessful.  The block will be called asynchronously on the main queue.
@@ -81,37 +80,38 @@ NS_ASSUME_NONNULL_BEGIN
 
 #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
 
-/// Starts an interactive consent flow on iOS to add scopes to the current user's grants.
+/// Starts an interactive consent flow on iOS to add new scopes to the user's `grantedScopes`.
 ///
-/// The completion will be called at the end of this process.  If successful, a `GIDUserAuth`
+/// The completion will be called at the end of this process.  If successful, a `GIDSignInResult`
 /// instance will be returned reflecting the new scopes and saved sign-in state will be updated.
 ///
 /// @param scopes The scopes to ask the user to consent to.
 /// @param presentingViewController The view controller used to present `SFSafariViewContoller` on
 ///     iOS 9 and 10 and to supply `presentationContextProvider` for `ASWebAuthenticationSession` on
 ///     iOS 13+.
-/// @param completion The block that is called on completion.  This block will be called asynchronously
-///     on the main queue.
+/// @param completion The optional block that is called on completion.  This block will be called
+///     asynchronously on the main queue.
 - (void)addScopes:(NSArray<NSString *> *)scopes
     presentingViewController:(UIViewController *)presentingViewController
-                  completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
+                  completion:(nullable void (^)(GIDSignInResult *_Nullable signInResult,
                                                 NSError *_Nullable error))completion
     NS_EXTENSION_UNAVAILABLE("The add scopes flow is not supported in App Extensions.");
 
 #elif TARGET_OS_OSX
 
-/// Starts an interactive consent flow on macOS to add scopes to the current user's grants.
+/// Starts an interactive consent flow on macOS to add new scopes to the user's `grantedScopes`.
 ///
-/// The completion will be called at the end of this process.  If successful, a `GIDUserAuth`
+/// The completion will be called at the end of this process.  If successful, a `GIDSignInResult`
 /// instance will be returned reflecting the new scopes and saved sign-in state will be updated.
 ///
 /// @param scopes An array of scopes to ask the user to consent to.
-/// @param presentingWindow The window used to supply `presentationContextProvider` for `ASWebAuthenticationSession`.
-/// @param completion The block that is called on completion.  This block will be called asynchronously
-///     on the main queue.
+/// @param presentingWindow The window used to supply `presentationContextProvider` for
+///     `ASWebAuthenticationSession`.
+/// @param completion The optional block that is called on completion.  This block will be called
+///     asynchronously on the main queue.
 - (void)addScopes:(NSArray<NSString *> *)scopes
     presentingWindow:(NSWindow *)presentingWindow
-          completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
+          completion:(nullable void (^)(GIDSignInResult *_Nullable signInResult,
                                         NSError *_Nullable error))completion;
 
 #endif

+ 30 - 26
GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h

@@ -25,7 +25,7 @@
 
 @class GIDConfiguration;
 @class GIDGoogleUser;
-@class GIDUserAuth;
+@class GIDSignInResult;
 
 NS_ASSUME_NONNULL_BEGIN
 
@@ -51,13 +51,13 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
   kGIDSignInErrorCodeMismatchWithCurrentUser = -9,
 };
 
-/// This class signs the user in with Google.
+/// This class is used to sign in users with their Google account and manage their session.
 ///
-/// For reference, please see "Google Sign-In for iOS" at
+/// For reference, please see "Google Sign-In for iOS and macOS" at
 /// https://developers.google.com/identity/sign-in/ios
 @interface GIDSignIn : NSObject
 
-/// A shared `GIDSignIn` instance.
+/// The shared `GIDSignIn` instance.
 @property(class, nonatomic, readonly) GIDSignIn *sharedInstance;
 
 /// The `GIDGoogleUser` object representing the current user or `nil` if there is no signed-in user.
@@ -81,29 +81,29 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
 /// @return `YES` if `GIDSignIn` handled this URL.
 - (BOOL)handleURL:(NSURL *)url;
 
-/// Checks if there is a previously authenticated user saved in keychain.
+/// Checks if there is a previous user sign-in saved in keychain.
 ///
-/// @return `YES` if there is a previously authenticated user saved in keychain.
+/// @return `YES` if there is a previous user sign-in saved in keychain.
 - (BOOL)hasPreviousSignIn;
 
-/// Attempts to restore a previously authenticated user without interaction.
+/// Attempts to restore a previous user sign-in without interaction.
 ///
 /// @param completion The block that is called on completion.  This block will be called asynchronously
 ///     on the main queue.
 - (void)restorePreviousSignInWithCompletion:(nullable void (^)(GIDGoogleUser *_Nullable user,
                                                                NSError *_Nullable error))completion;
 
-/// Marks current user as being in the signed out state.
+/// Signs out the `currentUser`, removing it from the keychain.
 - (void)signOut;
 
-/// Disconnects the current user from the app and revokes previous authentication. If the operation
-/// succeeds, the OAuth 2.0 token is also removed from keychain.
+/// Disconnects the `currentUser` by signing them out and revoking all OAuth2 scope grants made to the app.
 ///
 /// @param completion The optional block that is called on completion.
 ///     This block will be called asynchronously on the main queue.
 - (void)disconnectWithCompletion:(nullable void (^)(NSError *_Nullable error))completion;
 
 #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
+
 /// Starts an interactive sign-in flow on iOS.
 ///
 /// The completion will be called at the end of this process.  Any saved sign-in state will be
@@ -114,11 +114,12 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
 /// @param presentingViewController The view controller used to present `SFSafariViewContoller` on
 ///     iOS 9 and 10 and to supply `presentationContextProvider` for `ASWebAuthenticationSession` on
 ///     iOS 13+.
-/// @param completion The `GIDSignInCompletion` block that is called on completion.  This block will
+/// @param completion The optional block that is called on completion.  This block will
 ///     be called asynchronously on the main queue.
 - (void)signInWithPresentingViewController:(UIViewController *)presentingViewController
-                                completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
-                                                              NSError *_Nullable error))completion
+                                completion:
+    (nullable void (^)(GIDSignInResult *_Nullable signInResult,
+                       NSError *_Nullable error))completion
     NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions.");
 
 /// Starts an interactive sign-in flow on iOS using the provided hint.
@@ -133,12 +134,13 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
 ///     iOS 13+.
 /// @param hint An optional hint for the authorization server, for example the user's ID or email
 ///     address, to be prefilled if possible.
-/// @param completion The `GIDSignInCompletion` block that is called on completion.  This block will
+/// @param completion The optional block that is called on completion.  This block will
 ///     be called asynchronously on the main queue.
 - (void)signInWithPresentingViewController:(UIViewController *)presentingViewController
                                       hint:(nullable NSString *)hint
-                                completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
-                                                              NSError *_Nullable error))completion
+                                completion:
+    (nullable void (^)(GIDSignInResult *_Nullable signInResult,
+                       NSError *_Nullable error))completion
     NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions.");
 
 /// Starts an interactive sign-in flow on iOS using the provided hint and additional scopes.
@@ -153,16 +155,18 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
 /// @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 `GIDSignInCompletion` block that is called on completion.  This block will
+/// @param completion The optional block that is called on completion.  This block will
 ///     be called asynchronously on the main queue.
-
 - (void)signInWithPresentingViewController:(UIViewController *)presentingViewController
                                       hint:(nullable NSString *)hint
                           additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
-                                completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
-                                                              NSError *_Nullable error))completion;
+                                completion:
+    (nullable void (^)(GIDSignInResult *_Nullable signInResult,
+                       NSError *_Nullable error))completion
+    NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions.");
 
 #elif TARGET_OS_OSX
+
 /// Starts an interactive sign-in flow on macOS.
 ///
 /// The completion will be called at the end of this process.  Any saved sign-in state will be
@@ -171,10 +175,10 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
 /// `restorePreviousSignInWithCompletion:` method to restore a previous sign-in.
 ///
 /// @param presentingWindow The window used to supply `presentationContextProvider` for `ASWebAuthenticationSession`.
-/// @param completion The `GIDSignInCompletion` block that is called on completion.  This block will
+/// @param completion The optional block that is called on completion.  This block will
 ///     be called asynchronously on the main queue.
 - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
-                        completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
+                        completion:(nullable void (^)(GIDSignInResult *_Nullable signInResult,
                                                       NSError *_Nullable error))completion;
 
 /// Starts an interactive sign-in flow on macOS using the provided hint.
@@ -187,11 +191,11 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
 /// @param presentingWindow The window used to supply `presentationContextProvider` for `ASWebAuthenticationSession`.
 /// @param hint An optional hint for the authorization server, for example the user's ID or email
 ///     address, to be prefilled if possible.
-/// @param completion The `GIDSignInCompletion` block that is called on completion.  This block will
+/// @param completion The optional block that is called on completion.  This block will
 ///     be called asynchronously on the main queue.
 - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
                               hint:(nullable NSString *)hint
-                        completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
+                        completion:(nullable void (^)(GIDSignInResult *_Nullable signInResult,
                                                       NSError *_Nullable error))completion;
 
 /// Starts an interactive sign-in flow on macOS using the provided hint.
@@ -205,12 +209,12 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
 /// @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 `GIDSignInCompletion` block that is called on completion.  This block will
+/// @param completion The optional block that is called on completion.  This block will
 ///     be called asynchronously on the main queue.
 - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
                               hint:(nullable NSString *)hint
                   additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
-                        completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
+                        completion:(nullable void (^)(GIDSignInResult *_Nullable signInResult,
                                                       NSError *_Nullable error))completion;
 
 #endif

+ 4 - 4
GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignInButton.h

@@ -42,10 +42,10 @@ typedef NS_ENUM(NSInteger, GIDSignInButtonColorScheme) {
 
 /// This class provides the "Sign in with Google" button.
 ///
-/// You can instantiate this class programmatically or from a NIB file. You
-/// should connect this control to an `IBAction`, or something similar, that
-/// calls signInWithConfiguration:presentingViewController:callback: on
-/// `GIDSignIn` and add it to your view hierarchy.
+/// You can instantiate this class programmatically or from a NIB file. You should connect this
+/// control to an `IBAction`, or something similar, that calls
+/// signInWithPresentingViewController:completion: on `GIDSignIn` and add it to your view
+/// hierarchy.
 @interface GIDSignInButton : UIControl
 
 /// The layout style for the sign-in button.

+ 2 - 2
GoogleSignIn/Sources/Public/GoogleSignIn/GIDUserAuth.h → GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignInResult.h

@@ -20,8 +20,8 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
-/// A helper object that contains the outcome of a successful signIn or addScopes flow.
-@interface GIDUserAuth : NSObject
+/// A helper object that contains the result of a successful signIn or addScopes flow.
+@interface GIDSignInResult : NSObject
 
 /// The updated `GIDGoogleUser` instance for the user who just completed the flow.
 @property(nonatomic, readonly) GIDGoogleUser *user;

+ 1 - 1
GoogleSignIn/Sources/Public/GoogleSignIn/GIDToken.h

@@ -18,7 +18,7 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
-/// This class represents the basic information of a token.
+/// This class represents an OAuth2 or OpenID Connect token.
 @interface GIDToken : NSObject <NSSecureCoding>
 
 /// The token string.

+ 1 - 1
GoogleSignIn/Sources/Public/GoogleSignIn/GoogleSignIn.h

@@ -20,7 +20,7 @@
 #import "GIDProfileData.h"
 #import "GIDSignIn.h"
 #import "GIDToken.h"
-#import "GIDUserAuth.h"
+#import "GIDSignInResult.h"
 #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
 #import "GIDSignInButton.h"
 #endif

+ 4 - 4
GoogleSignIn/Tests/Unit/GIDGoogleUserTest.m

@@ -499,9 +499,9 @@ static NSString *const kNewScope = @"newScope";
 #elif TARGET_OS_OSX
               presentingWindow:[[NSWindow alloc] init]
 #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
-                    completion:^(GIDUserAuth *userAuth, NSError *error) {
+                    completion:^(GIDSignInResult *signInResult, NSError *error) {
     [expectation fulfill];
-    XCTAssertNil(userAuth);
+    XCTAssertNil(signInResult);
     XCTAssertEqual(error.code, kGIDSignInErrorCodeMismatchWithCurrentUser);
   }];
   
@@ -527,9 +527,9 @@ static NSString *const kNewScope = @"newScope";
 #elif TARGET_OS_OSX
               presentingWindow:[[NSWindow alloc] init]
 #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
-                    completion:^(GIDUserAuth *userAuth, NSError *error) {
+                    completion:^(GIDSignInResult *signInResult, NSError *error) {
     [expectation fulfill];
-    XCTAssertNil(userAuth);
+    XCTAssertNil(signInResult);
     XCTAssertEqual(error.code, kGIDSignInErrorCodeMismatchWithCurrentUser);
   }];
   

+ 4 - 4
GoogleSignIn/Tests/Unit/GIDSignInInternalOptionsTest.m

@@ -38,8 +38,8 @@
 #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
   NSString *loginHint = @"login_hint";
 
-  void (^completion)(GIDUserAuth *_Nullable userAuth, NSError *_Nullable error) =
-      ^(GIDUserAuth *_Nullable userAuth, NSError * _Nullable error) {};
+  GIDSignInCompletion completion = ^(GIDSignInResult *_Nullable signInResult,
+                                     NSError * _Nullable error) {};
   GIDSignInInternalOptions *options =
       [GIDSignInInternalOptions defaultOptionsWithConfiguration:configuration
 #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
@@ -64,8 +64,8 @@
 }
 
 - (void)testSilentOptions {
-  void (^completion)(GIDUserAuth *_Nullable userAuth, NSError *_Nullable error) =
-      ^(GIDUserAuth *_Nullable userAuth, NSError * _Nullable error) {};
+  GIDSignInCompletion completion = ^(GIDSignInResult *_Nullable signInResult,
+                                     NSError * _Nullable error) {};
   GIDSignInInternalOptions *options = [GIDSignInInternalOptions silentOptionsWithCompletion:completion];
   XCTAssertFalse(options.interactive);
   XCTAssertFalse(options.continuation);

+ 9 - 9
GoogleSignIn/Tests/Unit/GIDSignInTest.m

@@ -232,7 +232,7 @@ static NSString *const kNewScope = @"newScope";
   NSString *_hint;
 
   // The completion to be used when testing |GIDSignIn|.
-  GIDUserAuthCompletion _completion;
+  GIDSignInCompletion _completion;
 
   // The saved authorization request.
   OIDAuthorizationRequest *_savedAuthorizationRequest;
@@ -312,10 +312,10 @@ static NSString *const kNewScope = @"newScope";
   _hint = nil;
 
   __weak GIDSignInTest *weakSelf = self;
-  _completion = ^(GIDUserAuth *_Nullable userAuth, NSError * _Nullable error) {
+  _completion = ^(GIDSignInResult *_Nullable signInResult, NSError * _Nullable error) {
     GIDSignInTest *strongSelf = weakSelf;
-    if (!userAuth) {
-      XCTAssertNotNil(error, @"should have an error if the userAuth is nil");
+    if (!signInResult) {
+      XCTAssertNotNil(error, @"should have an error if the signInResult is nil");
     }
     XCTAssertFalse(strongSelf->_completionCalled, @"callback already called");
     strongSelf->_completionCalled = YES;
@@ -1215,13 +1215,13 @@ static NSString *const kNewScope = @"newScope";
     }
   } else {
     XCTestExpectation *expectation = [self expectationWithDescription:@"Callback called"];
-    GIDUserAuthCompletion completion =
-        ^(GIDUserAuth *_Nullable userAuth, NSError * _Nullable error) {
+    GIDSignInCompletion completion = ^(GIDSignInResult *_Nullable signInResult,
+                                       NSError * _Nullable error) {
       [expectation fulfill];
-      if (userAuth) {
-        XCTAssertEqualObjects(userAuth.serverAuthCode, kServerAuthCode);
+      if (signInResult) {
+        XCTAssertEqualObjects(signInResult.serverAuthCode, kServerAuthCode);
       } else {
-        XCTAssertNotNil(error, @"Should have an error if the userAuth is nil");
+        XCTAssertNotNil(error, @"Should have an error if the signInResult is nil");
       }
       XCTAssertFalse(self->_completionCalled, @"callback already called");
       self->_completionCalled = YES;

+ 4 - 8
README.md

@@ -76,10 +76,8 @@ Creating a 'Sign in with Google' button in SwiftUI can be as simple as this:
 
 ```
 GoogleSignInButton {
-  GIDSignIn.sharedInstance.signIn(
-    with: configuration, 
-    presenting: yourViewController) { user, error in
-      // check `error`; do something with `user`
+  GIDSignIn.sharedInstance.signIn(withPresenting: yourViewController) { signInResult, error in
+      // check `error`; do something with `signInResult`
   }
 }
 ```
@@ -111,10 +109,8 @@ that it will be available for use in AppKit.
 
 ```
 let signInButton = GoogleSignInButton {
-  GIDSignIn.sharedInstance.signIn(
-    with: configuration, 
-    presenting: yourViewController) { user, error in
-      // check `error`; do something with `user`
+  GIDSignIn.sharedInstance.signIn(withPresenting: yourViewController) { signInResult, error in
+      // check `error`; do something with `signInResult`
   }
 }
 let hostedButton = NSHostingView(rootView: signInButton)

+ 1 - 1
Samples/ObjC/SignInSample/Podfile

@@ -1,4 +1,4 @@
-platform :ios, '9.0'
+platform :ios, '10.0'
 
 target 'SampleForPod' do
   pod 'GoogleSignIn', :path => '../../../', :testspecs => ['unit']

+ 2 - 2
Samples/ObjC/SignInSample/Source/SignInViewController.m

@@ -248,7 +248,7 @@ static NSString *const kCredentialsButtonAccessibilityIdentifier = @"Credentials
 
 - (IBAction)signIn:(id)sender {
   [GIDSignIn.sharedInstance signInWithPresentingViewController:self
-                                                    completion:^(GIDUserAuth *userAuth,
+                                                    completion:^(GIDSignInResult *signInResult,
                                                                  NSError *error) {
     if (error) {
       self->_signInAuthStatus.text =
@@ -283,7 +283,7 @@ static NSString *const kCredentialsButtonAccessibilityIdentifier = @"Credentials
   GIDGoogleUser *currentUser = GIDSignIn.sharedInstance.currentUser;
   [currentUser addScopes:@[ @"https://www.googleapis.com/auth/user.birthday.read" ]
       presentingViewController:self
-                    completion:^(GIDUserAuth *_Nullable userAuth,
+                    completion:^(GIDSignInResult *_Nullable signInResult,
                                  NSError *_Nullable error) {
     if (error) {
       self->_signInAuthStatus.text = [NSString stringWithFormat:@"Status: Failed to add scopes: %@",

+ 16 - 15
Samples/Swift/DaysUntilBirthday/DaysUntilBirthday.xcodeproj/project.pbxproj

@@ -553,10 +553,10 @@
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
-				CODE_SIGN_IDENTITY = "iPhone Developer";
-				CODE_SIGN_STYLE = Manual;
+				CODE_SIGN_IDENTITY = "Apple Development";
+				CODE_SIGN_STYLE = Automatic;
 				DEVELOPMENT_ASSET_PATHS = "\"iOS/Preview Content\"";
-				DEVELOPMENT_TEAM = EQHXZ8M8AV;
+				DEVELOPMENT_TEAM = "";
 				ENABLE_PREVIEWS = YES;
 				INFOPLIST_FILE = iOS/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 14.0;
@@ -566,7 +566,7 @@
 				);
 				PRODUCT_BUNDLE_IDENTIFIER = com.google.DaysUntilBirthday;
 				PRODUCT_NAME = "$(TARGET_NAME)";
-				PROVISIONING_PROFILE_SPECIFIER = "Google Development";
+				PROVISIONING_PROFILE_SPECIFIER = "";
 				SWIFT_VERSION = 5.0;
 				TARGETED_DEVICE_FAMILY = "1,2";
 			};
@@ -577,10 +577,10 @@
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
-				CODE_SIGN_IDENTITY = "iPhone Developer";
-				CODE_SIGN_STYLE = Manual;
+				CODE_SIGN_IDENTITY = "Apple Development";
+				CODE_SIGN_STYLE = Automatic;
 				DEVELOPMENT_ASSET_PATHS = "\"iOS/Preview Content\"";
-				DEVELOPMENT_TEAM = EQHXZ8M8AV;
+				DEVELOPMENT_TEAM = "";
 				ENABLE_PREVIEWS = YES;
 				INFOPLIST_FILE = iOS/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 14.0;
@@ -590,7 +590,7 @@
 				);
 				PRODUCT_BUNDLE_IDENTIFIER = com.google.DaysUntilBirthday;
 				PRODUCT_NAME = "$(TARGET_NAME)";
-				PROVISIONING_PROFILE_SPECIFIER = "Google Development";
+				PROVISIONING_PROFILE_SPECIFIER = "";
 				SWIFT_VERSION = 5.0;
 				TARGETED_DEVICE_FAMILY = "1,2";
 			};
@@ -658,12 +658,12 @@
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
 				CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
 				CODE_SIGN_ENTITLEMENTS = macOS/DaysUntilBirthdayOnMac.entitlements;
-				CODE_SIGN_IDENTITY = "Mac Developer";
-				CODE_SIGN_STYLE = Manual;
+				CODE_SIGN_IDENTITY = "Apple Development";
+				CODE_SIGN_STYLE = Automatic;
 				COMBINE_HIDPI_IMAGES = YES;
 				CURRENT_PROJECT_VERSION = 1;
 				DEVELOPMENT_ASSET_PATHS = "\"macOS/Preview Content\"";
-				DEVELOPMENT_TEAM = EQHXZ8M8AV;
+				DEVELOPMENT_TEAM = "";
 				ENABLE_PREVIEWS = YES;
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_FILE = macOS/Info.plist;
@@ -676,7 +676,7 @@
 				MARKETING_VERSION = 1.0;
 				PRODUCT_BUNDLE_IDENTIFIER = Google.DaysUntilBirthdayOnMac;
 				PRODUCT_NAME = "$(TARGET_NAME)";
-				PROVISIONING_PROFILE_SPECIFIER = "Google Development macOS";
+				PROVISIONING_PROFILE_SPECIFIER = "";
 				SDKROOT = macosx;
 				SWIFT_EMIT_LOC_STRINGS = YES;
 				SWIFT_VERSION = 5.0;
@@ -690,11 +690,12 @@
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
 				CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
 				CODE_SIGN_ENTITLEMENTS = macOS/DaysUntilBirthdayOnMac.entitlements;
-				CODE_SIGN_STYLE = Manual;
+				CODE_SIGN_IDENTITY = "Apple Development";
+				CODE_SIGN_STYLE = Automatic;
 				COMBINE_HIDPI_IMAGES = YES;
 				CURRENT_PROJECT_VERSION = 1;
 				DEVELOPMENT_ASSET_PATHS = "\"macOS/Preview Content\"";
-				DEVELOPMENT_TEAM = EQHXZ8M8AV;
+				DEVELOPMENT_TEAM = "";
 				ENABLE_PREVIEWS = YES;
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_FILE = macOS/Info.plist;
@@ -707,7 +708,7 @@
 				MARKETING_VERSION = 1.0;
 				PRODUCT_BUNDLE_IDENTIFIER = Google.DaysUntilBirthdayOnMac;
 				PRODUCT_NAME = "$(TARGET_NAME)";
-				PROVISIONING_PROFILE_SPECIFIER = "Google Development macOS";
+				PROVISIONING_PROFILE_SPECIFIER = "";
 				SDKROOT = macosx;
 				SWIFT_EMIT_LOC_STRINGS = YES;
 				SWIFT_VERSION = 5.0;

+ 12 - 12
Samples/Swift/DaysUntilBirthday/Shared/Services/GoogleSignInAuthenticator.swift

@@ -36,12 +36,12 @@ final class GoogleSignInAuthenticator: ObservableObject {
       return
     }
 
-    GIDSignIn.sharedInstance.signIn(withPresenting: rootViewController) { userAuth, error in
-      guard let userAuth = userAuth else {
+    GIDSignIn.sharedInstance.signIn(withPresenting: rootViewController) { signInResult, error in
+      guard let signInResult = signInResult else {
         print("Error! \(String(describing: error))")
         return
       }
-      self.authViewModel.state = .signedIn(userAuth.user)
+      self.authViewModel.state = .signedIn(signInResult.user)
     }
 
 #elseif os(macOS)
@@ -50,12 +50,12 @@ final class GoogleSignInAuthenticator: ObservableObject {
       return
     }
 
-    GIDSignIn.sharedInstance.signIn(withPresenting: presentingWindow) { userAuth, error in
-      guard let userAuth = userAuth else {
+    GIDSignIn.sharedInstance.signIn(withPresenting: presentingWindow) { signInResult, error in
+      guard let signInResult = signInResult else {
         print("Error! \(String(describing: error))")
         return
       }
-      self.authViewModel.state = .signedIn(userAuth.user)
+      self.authViewModel.state = .signedIn(signInResult.user)
     }
 #endif
   }
@@ -93,14 +93,14 @@ final class GoogleSignInAuthenticator: ObservableObject {
     }
 
     currentUser.addScopes([BirthdayLoader.birthdayReadScope],
-                          presenting: rootViewController) { userAuth, error in
+                          presenting: rootViewController) { signInResult, error in
       if let error = error {
         print("Found error while adding birthday read scope: \(error).")
         return
       }
 
-      guard let userAuth = userAuth else { return }
-      self.authViewModel.state = .signedIn(userAuth.user)
+      guard let signInResult = signInResult else { return }
+      self.authViewModel.state = .signedIn(signInResult.user)
       completion()
     }
 
@@ -110,14 +110,14 @@ final class GoogleSignInAuthenticator: ObservableObject {
     }
 
     currentUser.addScopes([BirthdayLoader.birthdayReadScope],
-                          presenting: presentingWindow) { userAuth, error in
+                          presenting: presentingWindow) { signInResult, error in
       if let error = error {
         print("Found error while adding birthday read scope: \(error).")
         return
       }
 
-      guard let userAuth = userAuth else { return }
-      self.authViewModel.state = .signedIn(userAuth.user)
+      guard let signInResult = signInResult else { return }
+      self.authViewModel.state = .signedIn(signInResult.user)
       completion()
     }