|
|
@@ -34,6 +34,7 @@
|
|
|
#import "GoogleSignIn/Sources/GIDAuthentication_Private.h"
|
|
|
#import "GoogleSignIn/Sources/GIDGoogleUser_Private.h"
|
|
|
#import "GoogleSignIn/Sources/GIDProfileData_Private.h"
|
|
|
+#import "GoogleSignIn/Sources/GIDUserAuth_Private.h"
|
|
|
|
|
|
#ifdef SWIFT_PACKAGE
|
|
|
@import AppAuth;
|
|
|
@@ -187,7 +188,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
|
|
|
return [authState isAuthorized];
|
|
|
}
|
|
|
|
|
|
-- (void)restorePreviousSignInWithCallback:(nullable GIDSignInCallback)callback {
|
|
|
+- (void)restorePreviousSignInWithCallback:(nullable void (^)(GIDUserAuth *_Nullable userAuth, NSError *_Nullable error))callback {
|
|
|
[self signInWithOptions:[GIDSignInInternalOptions silentOptionsWithCallback:callback]];
|
|
|
}
|
|
|
|
|
|
@@ -217,7 +218,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
|
|
|
- (void)signInWithConfiguration:(GIDConfiguration *)configuration
|
|
|
presentingViewController:(UIViewController *)presentingViewController
|
|
|
hint:(nullable NSString *)hint
|
|
|
- callback:(nullable GIDSignInCallback)callback {
|
|
|
+ callback:(nullable void (^)(GIDUserAuth *_Nullable userAuth, NSError *_Nullable error))callback {
|
|
|
GIDSignInInternalOptions *options =
|
|
|
[GIDSignInInternalOptions defaultOptionsWithConfiguration:configuration
|
|
|
presentingViewController:presentingViewController
|
|
|
@@ -231,7 +232,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
|
|
|
presentingViewController:(UIViewController *)presentingViewController
|
|
|
hint:(nullable NSString *)hint
|
|
|
additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
|
|
|
- callback:(nullable GIDSignInCallback)callback {
|
|
|
+ callback:(nullable void (^)(GIDUserAuth *_Nullable userAuth, NSError *_Nullable error))callback {
|
|
|
GIDSignInInternalOptions *options =
|
|
|
[GIDSignInInternalOptions defaultOptionsWithConfiguration:configuration
|
|
|
presentingViewController:presentingViewController
|
|
|
@@ -244,7 +245,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
|
|
|
|
|
|
- (void)signInWithConfiguration:(GIDConfiguration *)configuration
|
|
|
presentingViewController:(UIViewController *)presentingViewController
|
|
|
- callback:(nullable GIDSignInCallback)callback {
|
|
|
+ callback:(nullable void (^)(GIDUserAuth *_Nullable userAuth, NSError *_Nullable error))callback {
|
|
|
[self signInWithConfiguration:configuration
|
|
|
presentingViewController:presentingViewController
|
|
|
hint:nil
|
|
|
@@ -253,7 +254,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
|
|
|
|
|
|
- (void)addScopes:(NSArray<NSString *> *)scopes
|
|
|
presentingViewController:(UIViewController *)presentingViewController
|
|
|
- callback:(nullable GIDSignInCallback)callback {
|
|
|
+ callback:(nullable void (^)(GIDUserAuth *_Nullable userAuth, NSError *_Nullable error))callback {
|
|
|
// A currentUser must be available in order to complete this flow.
|
|
|
if (!self.currentUser) {
|
|
|
// No currentUser is set, notify callback of failure.
|
|
|
@@ -310,7 +311,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
|
|
|
- (void)signInWithConfiguration:(GIDConfiguration *)configuration
|
|
|
presentingWindow:(NSWindow *)presentingWindow
|
|
|
hint:(nullable NSString *)hint
|
|
|
- callback:(nullable GIDSignInCallback)callback {
|
|
|
+ callback:(nullable void (^)(GIDUserAuth *_Nullable userAuth, NSError *_Nullable error))callback {
|
|
|
GIDSignInInternalOptions *options =
|
|
|
[GIDSignInInternalOptions defaultOptionsWithConfiguration:configuration
|
|
|
presentingWindow:presentingWindow
|
|
|
@@ -322,7 +323,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
|
|
|
|
|
|
- (void)signInWithConfiguration:(GIDConfiguration *)configuration
|
|
|
presentingWindow:(NSWindow *)presentingWindow
|
|
|
- callback:(nullable GIDSignInCallback)callback {
|
|
|
+ callback:(nullable void (^)(GIDUserAuth *_Nullable userAuth, NSError *_Nullable error))callback {
|
|
|
[self signInWithConfiguration:configuration
|
|
|
presentingWindow:presentingWindow
|
|
|
hint:nil
|
|
|
@@ -333,7 +334,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
|
|
|
presentingWindow:(NSWindow *)presentingWindow
|
|
|
hint:(nullable NSString *)hint
|
|
|
additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
|
|
|
- callback:(nullable GIDSignInCallback)callback {
|
|
|
+ callback:(nullable void (^)(GIDUserAuth *_Nullable userAuth, NSError *_Nullable error))callback {
|
|
|
GIDSignInInternalOptions *options =
|
|
|
[GIDSignInInternalOptions defaultOptionsWithConfiguration:configuration
|
|
|
presentingWindow:presentingWindow
|
|
|
@@ -346,7 +347,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
|
|
|
|
|
|
- (void)addScopes:(NSArray<NSString *> *)scopes
|
|
|
presentingWindow:(NSWindow *)presentingWindow
|
|
|
- callback:(nullable GIDSignInCallback)callback {
|
|
|
+ callback:(nullable void (^)(GIDUserAuth *_Nullable userAuth, NSError *_Nullable error))callback {
|
|
|
// A currentUser must be available in order to complete this flow.
|
|
|
if (!self.currentUser) {
|
|
|
// No currentUser is set, notify callback of failure.
|
|
|
@@ -541,7 +542,8 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
|
|
|
if (options.callback) {
|
|
|
self->_currentOptions = nil;
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
- options.callback(self->_currentUser, nil);
|
|
|
+ GIDUserAuth *userAuth = [[GIDUserAuth alloc]initWithGoogleUser:self->_currentUser serverAuthCode:nil];
|
|
|
+ options.callback(userAuth, nil);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
@@ -601,7 +603,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
|
|
|
_currentAuthorizationFlow = [OIDAuthorizationService
|
|
|
presentAuthorizationRequest:request
|
|
|
presentingViewController:options.presentingViewController
|
|
|
- callback:^(OIDAuthorizationResponse *_Nullable authorizationResponse,
|
|
|
+ callback:^(OIDAuthorizationResponse *_Nullable authorizationResponse,
|
|
|
NSError *_Nullable error) {
|
|
|
[self processAuthorizationResponse:authorizationResponse
|
|
|
error:error
|
|
|
@@ -882,10 +884,13 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
|
|
|
[authFlow addCallback:^() {
|
|
|
GIDAuthFlow *handlerAuthFlow = weakAuthFlow;
|
|
|
if (self->_currentOptions.callback) {
|
|
|
- GIDSignInCallback callback = self->_currentOptions.callback;
|
|
|
+ void (^callback)(GIDUserAuth *_Nullable userAuth, NSError *_Nullable error) = self->_currentOptions.callback;
|
|
|
self->_currentOptions = nil;
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
- callback(self->_currentUser, handlerAuthFlow.error);
|
|
|
+ OIDAuthState *authState = handlerAuthFlow.authState;
|
|
|
+ NSString * _Nullable serverAuthCode = [authState.lastTokenResponse.additionalParameters[@"server_code"] copy];
|
|
|
+ GIDUserAuth * userAuth = [[GIDUserAuth alloc]initWithGoogleUser:self->_currentUser serverAuthCode:serverAuthCode];
|
|
|
+ callback(userAuth, handlerAuthFlow.error);
|
|
|
});
|
|
|
}
|
|
|
}];
|