Przeglądaj źródła

Merge branch 'main' into mdmathias/async-support

Peter Andrews 3 lat temu
rodzic
commit
38a5f5cd0d

+ 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
 

+ 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

+ 29 - 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,17 +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
@@ -172,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.
@@ -188,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.
@@ -206,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

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

+ 8 - 9
Samples/Swift/DaysUntilBirthday/Shared/Services/GoogleSignInAuthenticator.swift

@@ -32,13 +32,12 @@ final class GoogleSignInAuthenticator {
     self.authViewModel = authViewModel
   }
 
-
 #if os(iOS)
   /// Signs in the user based upon the selected account.
   /// - parameter rootViewController: The `UIViewController` to use during the sign in flow.
-  /// - returns: The resulting`GIDUserAuth`.
+  /// - returns: The `GIDSignInResult`.
   /// - throws: Any error that may arise during the sign in process.
-  func signIn(with rootViewController: UIViewController) async throws -> GIDUserAuth {
+  func signIn(with rootViewController: UIViewController) async throws -> GIDSignInResult {
     return try await GIDSignIn.sharedInstance.signIn(withPresenting: rootViewController)
   }
 #endif
@@ -46,9 +45,9 @@ final class GoogleSignInAuthenticator {
 #if os(macOS)
   /// Signs in the user based upon the selected account.
   /// - parameter window: The `NSWindow` to use during the sign in flow.
-  /// - returns: The resulting`GIDUserAuth`.
+  /// - returns: The `GIDSignInResult`.
   /// - throws: Any error that may arise during the sign in process.
-  func signIn(with window: NSWindow) async throws -> GIDUserAuth {
+  func signIn(with window: NSWindow) async throws -> GIDSignInResult {
     return try await GIDSignIn.sharedInstance.signIn(withPresenting: window)
   }
 #endif
@@ -67,9 +66,9 @@ final class GoogleSignInAuthenticator {
 #if os(iOS)
   /// Adds the birthday read scope for the current user.
   /// - parameter viewController: The `UIViewController` to use while authorizing the scope.
-  /// - returns: The resulting`GIDUserAuth`.
+  /// - returns: The `GIDSignInResult`.
   /// - throws: Any error that may arise while authorizing the scope.
-  func addBirthdayReadScope(viewController: UIViewController) async throws -> GIDUserAuth {
+  func addBirthdayReadScope(viewController: UIViewController) async throws -> GIDSignInResult {
     guard let currentUser = GIDSignIn.sharedInstance.currentUser else {
       fatalError("No currentUser!")
     }
@@ -83,9 +82,9 @@ final class GoogleSignInAuthenticator {
 #if os(macOS)
   /// Adds the birthday read scope for the current user.
   /// - parameter window: The `NSWindow` to use while authorizing the scope.
-  /// - returns: The resulting`GIDUserAuth`.
+  /// - returns: The `GIDSignInResult`.
   /// - throws: Any error that may arise while authorizing the scope.
-  func addBirthdayReadScope(window: NSWindow) async throws -> GIDUserAuth {
+  func addBirthdayReadScope(window: NSWindow) async throws -> GIDSignInResult {
     guard let currentUser = GIDSignIn.sharedInstance.currentUser else {
       fatalError("No currentUser!")
     }