Skip to content

Commit 38a5f5c

Browse files
authored
Merge branch 'main' into mdmathias/async-support
2 parents a75b5ab + 019a3a7 commit 38a5f5c

File tree

18 files changed

+135
-141
lines changed

18 files changed

+135
-141
lines changed

GoogleSignIn/Sources/GIDGoogleUser.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ - (void)addScopes:(NSArray<NSString *> *)scopes
189189
#elif TARGET_OS_OSX
190190
presentingWindow:(NSWindow *)presentingWindow
191191
#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
192-
completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
192+
completion:(nullable void (^)(GIDSignInResult *_Nullable signInResult,
193193
NSError *_Nullable error))completion {
194194
if (self != GIDSignIn.sharedInstance.currentUser) {
195195
NSError *error = [NSError errorWithDomain:kGIDSignInErrorDomain

GoogleSignIn/Sources/GIDSignIn.m

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDConfiguration.h"
2020
#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDGoogleUser.h"
2121
#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDProfileData.h"
22-
#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDUserAuth.h"
22+
#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignInResult.h"
2323

2424
#import "GoogleSignIn/Sources/GIDEMMSupport.h"
2525
#import "GoogleSignIn/Sources/GIDSignInInternalOptions.h"
@@ -34,7 +34,7 @@
3434

3535
#import "GoogleSignIn/Sources/GIDGoogleUser_Private.h"
3636
#import "GoogleSignIn/Sources/GIDProfileData_Private.h"
37-
#import "GoogleSignIn/Sources/GIDUserAuth_Private.h"
37+
#import "GoogleSignIn/Sources/GIDSignInResult_Private.h"
3838

3939
#ifdef SWIFT_PACKAGE
4040
@import AppAuth;
@@ -201,9 +201,9 @@ - (BOOL)hasPreviousSignIn {
201201
- (void)restorePreviousSignInWithCompletion:(nullable void (^)(GIDGoogleUser *_Nullable user,
202202
NSError *_Nullable error))completion {
203203
[self signInWithOptions:[GIDSignInInternalOptions silentOptionsWithCompletion:
204-
^(GIDUserAuth *userAuth, NSError *error) {
205-
if (userAuth) {
206-
completion(userAuth.user, nil);
204+
^(GIDSignInResult *signInResult, NSError *error) {
205+
if (signInResult) {
206+
completion(signInResult.user, nil);
207207
} else {
208208
completion(nil, error);
209209
}
@@ -235,7 +235,7 @@ - (BOOL)restorePreviousSignInNoRefresh {
235235

236236
- (void)signInWithPresentingViewController:(UIViewController *)presentingViewController
237237
hint:(nullable NSString *)hint
238-
completion:(nullable GIDUserAuthCompletion)completion {
238+
completion:(nullable GIDSignInCompletion)completion {
239239
GIDSignInInternalOptions *options =
240240
[GIDSignInInternalOptions defaultOptionsWithConfiguration:_configuration
241241
presentingViewController:presentingViewController
@@ -248,7 +248,7 @@ - (void)signInWithPresentingViewController:(UIViewController *)presentingViewCon
248248
- (void)signInWithPresentingViewController:(UIViewController *)presentingViewController
249249
hint:(nullable NSString *)hint
250250
additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
251-
completion:(nullable GIDUserAuthCompletion)completion {
251+
completion:(nullable GIDSignInCompletion)completion {
252252
GIDSignInInternalOptions *options =
253253
[GIDSignInInternalOptions defaultOptionsWithConfiguration:_configuration
254254
presentingViewController:presentingViewController
@@ -260,15 +260,15 @@ - (void)signInWithPresentingViewController:(UIViewController *)presentingViewCon
260260
}
261261

262262
- (void)signInWithPresentingViewController:(UIViewController *)presentingViewController
263-
completion:(nullable GIDUserAuthCompletion)completion {
263+
completion:(nullable GIDSignInCompletion)completion {
264264
[self signInWithPresentingViewController:presentingViewController
265265
hint:nil
266266
completion:completion];
267267
}
268268

269269
- (void)addScopes:(NSArray<NSString *> *)scopes
270270
presentingViewController:(UIViewController *)presentingViewController
271-
completion:(nullable GIDUserAuthCompletion)completion {
271+
completion:(nullable GIDSignInCompletion)completion {
272272
GIDConfiguration *configuration = self.currentUser.configuration;
273273
GIDSignInInternalOptions *options =
274274
[GIDSignInInternalOptions defaultOptionsWithConfiguration:configuration
@@ -306,7 +306,7 @@ - (void)addScopes:(NSArray<NSString *> *)scopes
306306

307307
- (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
308308
hint:(nullable NSString *)hint
309-
completion:(nullable GIDUserAuthCompletion)completion {
309+
completion:(nullable GIDSignInCompletion)completion {
310310
GIDSignInInternalOptions *options =
311311
[GIDSignInInternalOptions defaultOptionsWithConfiguration:_configuration
312312
presentingWindow:presentingWindow
@@ -317,7 +317,7 @@ - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
317317
}
318318

319319
- (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
320-
completion:(nullable GIDUserAuthCompletion)completion {
320+
completion:(nullable GIDSignInCompletion)completion {
321321
[self signInWithPresentingWindow:presentingWindow
322322
hint:nil
323323
completion:completion];
@@ -326,7 +326,7 @@ - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
326326
- (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
327327
hint:(nullable NSString *)hint
328328
additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
329-
completion:(nullable GIDUserAuthCompletion)completion {
329+
completion:(nullable GIDSignInCompletion)completion {
330330
GIDSignInInternalOptions *options =
331331
[GIDSignInInternalOptions defaultOptionsWithConfiguration:_configuration
332332
presentingWindow:presentingWindow
@@ -339,7 +339,7 @@ - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
339339

340340
- (void)addScopes:(NSArray<NSString *> *)scopes
341341
presentingWindow:(NSWindow *)presentingWindow
342-
completion:(nullable GIDUserAuthCompletion)completion {
342+
completion:(nullable GIDSignInCompletion)completion {
343343
GIDConfiguration *configuration = self.currentUser.configuration;
344344
GIDSignInInternalOptions *options =
345345
[GIDSignInInternalOptions defaultOptionsWithConfiguration:configuration
@@ -529,8 +529,9 @@ - (void)signInWithOptions:(GIDSignInInternalOptions *)options {
529529
if (options.completion) {
530530
self->_currentOptions = nil;
531531
dispatch_async(dispatch_get_main_queue(), ^{
532-
GIDUserAuth *userAuth = [[GIDUserAuth alloc] initWithGoogleUser:self->_currentUser serverAuthCode:nil];
533-
options.completion(userAuth, nil);
532+
GIDSignInResult *signInResult =
533+
[[GIDSignInResult alloc] initWithGoogleUser:self->_currentUser serverAuthCode:nil];
534+
options.completion(signInResult, nil);
534535
});
535536
}
536537
}
@@ -843,7 +844,7 @@ - (void)addCompletionCallback:(GIDAuthFlow *)authFlow {
843844
[authFlow addCallback:^() {
844845
GIDAuthFlow *handlerAuthFlow = weakAuthFlow;
845846
if (self->_currentOptions.completion) {
846-
GIDUserAuthCompletion completion = self->_currentOptions.completion;
847+
GIDSignInCompletion completion = self->_currentOptions.completion;
847848
self->_currentOptions = nil;
848849
dispatch_async(dispatch_get_main_queue(), ^{
849850
if (handlerAuthFlow.error) {
@@ -852,9 +853,10 @@ - (void)addCompletionCallback:(GIDAuthFlow *)authFlow {
852853
OIDAuthState *authState = handlerAuthFlow.authState;
853854
NSString *_Nullable serverAuthCode =
854855
[authState.lastTokenResponse.additionalParameters[@"server_code"] copy];
855-
GIDUserAuth *userAuth = [[GIDUserAuth alloc] initWithGoogleUser:self->_currentUser
856-
serverAuthCode:serverAuthCode];
857-
completion(userAuth, nil);
856+
GIDSignInResult *signInResult =
857+
[[GIDSignInResult alloc] initWithGoogleUser:self->_currentUser
858+
serverAuthCode:serverAuthCode];
859+
completion(signInResult, nil);
858860
}
859861
});
860862
}

GoogleSignIn/Sources/GIDSignInInternalOptions.h

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
#import <AppKit/AppKit.h>
2323
#endif
2424

25+
#import "GoogleSignIn/Sources/GIDSignIn_Private.h"
26+
2527
@class GIDConfiguration;
26-
@class GIDUserAuth;
28+
@class GIDSignInResult;
2729

2830
NS_ASSUME_NONNULL_BEGIN
2931

@@ -54,8 +56,7 @@ NS_ASSUME_NONNULL_BEGIN
5456
#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
5557

5658
/// The completion block to be called at the completion of the flow.
57-
@property(nonatomic, readonly, nullable) void (^completion)(GIDUserAuth *_Nullable userAuth,
58-
NSError *_Nullable error);
59+
@property(nonatomic, readonly, nullable) GIDSignInCompletion completion;
5960

6061
/// The scopes to be used during the flow.
6162
@property(nonatomic, copy, nullable) NSArray<NSString *> *scopes;
@@ -69,37 +70,32 @@ NS_ASSUME_NONNULL_BEGIN
6970
presentingViewController:(nullable UIViewController *)presentingViewController
7071
loginHint:(nullable NSString *)loginHint
7172
addScopesFlow:(BOOL)addScopesFlow
72-
completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
73-
NSError *_Nullable error))completion;
73+
completion:(nullable GIDSignInCompletion)completion;
7474

7575
+ (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
7676
presentingViewController:(nullable UIViewController *)presentingViewController
7777
loginHint:(nullable NSString *)loginHint
7878
addScopesFlow:(BOOL)addScopesFlow
7979
scopes:(nullable NSArray *)scopes
80-
completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
81-
NSError *_Nullable error))completion;
80+
completion:(nullable GIDSignInCompletion)completion;
8281

8382
#elif TARGET_OS_OSX
8483
+ (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
8584
presentingWindow:(nullable NSWindow *)presentingWindow
8685
loginHint:(nullable NSString *)loginHint
8786
addScopesFlow:(BOOL)addScopesFlow
88-
completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
89-
NSError *_Nullable error))completion;
87+
completion:(nullable GIDSignInCompletion)completion;
9088

9189
+ (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
9290
presentingWindow:(nullable NSWindow *)presentingWindow
9391
loginHint:(nullable NSString *)loginHint
9492
addScopesFlow:(BOOL)addScopesFlow
9593
scopes:(nullable NSArray *)scopes
96-
completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
97-
NSError *_Nullable error))completion;
94+
completion:(nullable GIDSignInCompletion)completion;
9895
#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
9996

10097
/// Creates the options to sign in silently.
101-
+ (instancetype)silentOptionsWithCompletion:(void (^)(GIDUserAuth *_Nullable userAuth,
102-
NSError *_Nullable error))completion;
98+
+ (instancetype)silentOptionsWithCompletion:(GIDSignInCompletion)completion;
10399

104100
/// Creates options with the same values as the receiver, except for the "extra parameters", and
105101
/// continuation flag, which are replaced by the arguments passed to this method.

GoogleSignIn/Sources/GIDSignInInternalOptions.m

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,14 @@ + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)con
3131
loginHint:(nullable NSString *)loginHint
3232
addScopesFlow:(BOOL)addScopesFlow
3333
scopes:(nullable NSArray *)scopes
34-
completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
35-
NSError *_Nullable error))completion {
34+
completion:(nullable GIDSignInCompletion)completion {
3635
#elif TARGET_OS_OSX
3736
+ (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
3837
presentingWindow:(nullable NSWindow *)presentingWindow
3938
loginHint:(nullable NSString *)loginHint
4039
addScopesFlow:(BOOL)addScopesFlow
4140
scopes:(nullable NSArray *)scopes
42-
completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
43-
NSError *_Nullable error))completion {
41+
completion:(nullable GIDSignInCompletion)completion {
4442
#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
4543
GIDSignInInternalOptions *options = [[GIDSignInInternalOptions alloc] init];
4644
if (options) {
@@ -65,15 +63,13 @@ + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)con
6563
presentingViewController:(nullable UIViewController *)presentingViewController
6664
loginHint:(nullable NSString *)loginHint
6765
addScopesFlow:(BOOL)addScopesFlow
68-
completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
69-
NSError *_Nullable error))completion {
66+
completion:(nullable GIDSignInCompletion)completion {
7067
#elif TARGET_OS_OSX
7168
+ (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)configuration
7269
presentingWindow:(nullable NSWindow *)presentingWindow
7370
loginHint:(nullable NSString *)loginHint
7471
addScopesFlow:(BOOL)addScopesFlow
75-
completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
76-
NSError *_Nullable error))completion {
72+
completion:(nullable GIDSignInCompletion)completion {
7773
#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
7874
GIDSignInInternalOptions *options = [self defaultOptionsWithConfiguration:configuration
7975
#if TARGET_OS_IOS || TARGET_OS_MACCATALYST
@@ -88,8 +84,7 @@ + (instancetype)defaultOptionsWithConfiguration:(nullable GIDConfiguration *)con
8884
return options;
8985
}
9086

91-
+ (instancetype)silentOptionsWithCompletion:(void (^)(GIDUserAuth *_Nullable userAuth,
92-
NSError *_Nullable error))completion {
87+
+ (instancetype)silentOptionsWithCompletion:(GIDSignInCompletion)completion {
9388
GIDSignInInternalOptions *options = [self defaultOptionsWithConfiguration:nil
9489
#if TARGET_OS_IOS || TARGET_OS_MACCATALYST
9590
presentingViewController:nil

GoogleSignIn/Sources/GIDUserAuth.m renamed to GoogleSignIn/Sources/GIDSignInResult.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 Google LLC
2+
* Copyright 2022 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,12 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDUserAuth.h"
17+
#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignInResult.h"
1818

19-
#import "GoogleSignIn/Sources/GIDUserAuth_Private.h"
19+
#import "GoogleSignIn/Sources/GIDSignInResult_Private.h"
2020
#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDGoogleUser.h"
2121

22-
@implementation GIDUserAuth
22+
@implementation GIDSignInResult
2323

2424
- (instancetype)initWithGoogleUser:(GIDGoogleUser *)user
2525
serverAuthCode:(nullable NSString *)serverAuthCode {

GoogleSignIn/Sources/GIDUserAuth_Private.h renamed to GoogleSignIn/Sources/GIDSignInResult_Private.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDUserAuth.h"
17+
#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignInResult.h"
1818

1919
NS_ASSUME_NONNULL_BEGIN
2020

21-
// Private |GIDUserAuth| methods that are used in this SDK.
22-
@interface GIDUserAuth ()
21+
// Private |GIDSignInResult| methods that are used in this SDK.
22+
@interface GIDSignInResult ()
2323

24-
// Private initializer for |GIDUserAuth|.
24+
// Private initializer for |GIDSignInResult|.
2525
// @param user The current GIDGoogleUser.
2626
// @param severAuthCode The one-time authorization code for backend to exchange
2727
// access and refresh tokens.

GoogleSignIn/Sources/GIDSignIn_Private.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ NS_ASSUME_NONNULL_BEGIN
2929
@class GIDGoogleUser;
3030
@class GIDSignInInternalOptions;
3131

32-
/// Represents a completion block that takes a `GIDUserAuth` on success or an error if the operation
33-
/// was unsuccessful.
34-
typedef void (^GIDUserAuthCompletion)(GIDUserAuth *_Nullable userAuth, NSError *_Nullable error);
32+
/// Represents a completion block that takes a `GIDSignInResult` on success or an error if the
33+
/// operation was unsuccessful.
34+
typedef void (^GIDSignInCompletion)(GIDSignInResult *_Nullable signInResult,
35+
NSError *_Nullable error);
3536

3637
/// Represents a completion block that takes an error if the operation was unsuccessful.
3738
typedef void (^GIDDisconnectCompletion)(NSError *_Nullable error);
@@ -60,7 +61,7 @@ typedef void (^GIDDisconnectCompletion)(NSError *_Nullable error);
6061

6162
/// Starts an interactive consent flow on iOS to add scopes to the current user's grants.
6263
///
63-
/// The completion will be called at the end of this process. If successful, a `GIDUserAuth`
64+
/// The completion will be called at the end of this process. If successful, a `GIDSignInResult`
6465
/// instance will be returned reflecting the new scopes and saved sign-in state will be updated.
6566
///
6667
/// @param scopes The scopes to ask the user to consent to.
@@ -71,15 +72,14 @@ typedef void (^GIDDisconnectCompletion)(NSError *_Nullable error);
7172
/// on the main queue.
7273
- (void)addScopes:(NSArray<NSString *> *)scopes
7374
presentingViewController:(UIViewController *)presentingViewController
74-
completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
75-
NSError *_Nullable error))completion
75+
completion:(nullable GIDSignInCompletion)completion
7676
NS_EXTENSION_UNAVAILABLE("The add scopes flow is not supported in App Extensions.");
7777

7878
#elif TARGET_OS_OSX
7979

8080
/// Starts an interactive consent flow on macOS to add scopes to the current user's grants.
8181
///
82-
/// The completion will be called at the end of this process. If successful, a `GIDUserAuth`
82+
/// The completion will be called at the end of this process. If successful, a `GIDSignInResult`
8383
/// instance will be returned reflecting the new scopes and saved sign-in state will be updated.
8484
///
8585
/// @param scopes An array of scopes to ask the user to consent to.
@@ -89,8 +89,7 @@ typedef void (^GIDDisconnectCompletion)(NSError *_Nullable error);
8989
/// on the main queue.
9090
- (void)addScopes:(NSArray<NSString *> *)scopes
9191
presentingWindow:(NSWindow *)presentingWindow
92-
completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth,
93-
NSError *_Nullable error))completion;
92+
completion:(nullable GIDSignInCompletion)completion;
9493

9594
#endif
9695

0 commit comments

Comments
 (0)