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

Rename `GIDUserAuth` to `GIDSignInResult` (#268)

Peter Andrews 3 лет назад
Родитель
Сommit
019a3a76e5

+ 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/GIDSignInInternalOptions.h"
@@ -34,7 +34,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;
@@ -201,9 +201,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);
     }
@@ -235,7 +235,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
@@ -248,7 +248,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
@@ -260,7 +260,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];
@@ -268,7 +268,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
@@ -306,7 +306,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
@@ -317,7 +317,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];
@@ -326,7 +326,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
@@ -339,7 +339,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
@@ -529,8 +529,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);
           });
         }
       }
@@ -843,7 +844,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) {
@@ -852,9 +853,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.

+ 8 - 9
GoogleSignIn/Sources/GIDSignIn_Private.h

@@ -29,9 +29,10 @@ NS_ASSUME_NONNULL_BEGIN
 @class GIDGoogleUser;
 @class GIDSignInInternalOptions;
 
-/// Represents a completion block that takes a `GIDUserAuth` on success or an error if the operation
-/// 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);
@@ -60,7 +61,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.
@@ -71,15 +72,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.
@@ -89,8 +89,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
 

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

@@ -32,7 +32,7 @@
 #endif
 
 @class GIDConfiguration;
-@class GIDUserAuth;
+@class GIDSignInResult;
 @class GIDToken;
 @class GIDProfileData;
 
@@ -82,7 +82,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 /// 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.
@@ -93,7 +93,7 @@ NS_ASSUME_NONNULL_BEGIN
 ///     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.");
 
@@ -101,7 +101,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 /// 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.
@@ -111,7 +111,7 @@ NS_ASSUME_NONNULL_BEGIN
 ///     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

+ 13 - 11
GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h

@@ -25,7 +25,7 @@
 
 @class GIDConfiguration;
 @class GIDGoogleUser;
-@class GIDUserAuth;
+@class GIDSignInResult;
 
 NS_ASSUME_NONNULL_BEGIN
 
@@ -117,8 +117,9 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
 /// @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.
@@ -137,8 +138,9 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
 ///     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.
@@ -155,12 +157,12 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
 /// @param additionalScopes An optional array of scopes to request in addition to the basic profile scopes.
 /// @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
@@ -176,7 +178,7 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
 /// @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.
@@ -193,7 +195,7 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
 ///     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.
@@ -212,7 +214,7 @@ typedef NS_ERROR_ENUM(kGIDSignInErrorDomain, GIDSignInErrorCode) {
 - (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

+ 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/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

@@ -235,7 +235,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;
@@ -334,10 +334,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;
@@ -1249,13 +1249,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;

+ 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: %@",

+ 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()
     }