@@ -234,12 +234,25 @@ - (void)signInWithPresentingViewController:(UIViewController *)presentingViewCon
234234 hint : (nullable NSString *)hint
235235 additionalScopes : (nullable NSArray <NSString *> *)additionalScopes
236236 completion : (nullable GIDSignInCompletion)completion {
237+ [self signInWithPresentingViewController: presentingViewController
238+ hint: hint
239+ additionalScopes: additionalScopes
240+ nonce: nil
241+ completion: completion];
242+ }
243+
244+ - (void )signInWithPresentingViewController : (UIViewController *)presentingViewController
245+ hint : (nullable NSString *)hint
246+ additionalScopes : (nullable NSArray <NSString *> *)additionalScopes
247+ nonce : (nullable NSString *)nonce
248+ completion : (nullable GIDSignInCompletion)completion {
237249 GIDSignInInternalOptions *options =
238250 [GIDSignInInternalOptions defaultOptionsWithConfiguration: _configuration
239251 presentingViewController: presentingViewController
240252 loginHint: hint
241253 addScopesFlow: NO
242254 scopes: additionalScopes
255+ nonce: nonce
243256 completion: completion];
244257 [self signInWithOptions: options];
245258}
@@ -315,12 +328,25 @@ - (void)signInWithPresentingWindow:(NSWindow *)presentingWindow
315328 hint : (nullable NSString *)hint
316329 additionalScopes : (nullable NSArray <NSString *> *)additionalScopes
317330 completion : (nullable GIDSignInCompletion)completion {
331+ [self signInWithPresentingWindow: presentingWindow
332+ hint: hint
333+ additionalScopes: additionalScopes
334+ nonce: nil
335+ completion: completion];
336+ }
337+
338+ - (void )signInWithPresentingWindow : (NSWindow *)presentingWindow
339+ hint : (nullable NSString *)hint
340+ additionalScopes : (nullable NSArray <NSString *> *)additionalScopes
341+ nonce : (nullable NSString *)nonce
342+ completion : (nullable GIDSignInCompletion)completion {
318343 GIDSignInInternalOptions *options =
319344 [GIDSignInInternalOptions defaultOptionsWithConfiguration: _configuration
320345 presentingWindow: presentingWindow
321346 loginHint: hint
322347 addScopesFlow: NO
323348 scopes: additionalScopes
349+ nonce: nonce
324350 completion: completion];
325351 [self signInWithOptions: options];
326352}
@@ -539,7 +565,7 @@ - (void)signInWithOptions:(GIDSignInInternalOptions *)options {
539565 if (!_configuration) {
540566 // NOLINTNEXTLINE(google-objc-avoid-throwing-exception)
541567 [NSException raise: NSInvalidArgumentException
542- format: @" No active configuration. Make sure GIDClientID is set in Info.plist." ];
568+ format: @" No active configuration. Make sure GIDClientID is set in Info.plist." ];
543569 return ;
544570 }
545571
@@ -633,7 +659,6 @@ - (void)authorizationRequestWithOptions:(GIDSignInInternalOptions *)options comp
633659 [_timedLoader startTiming ];
634660 [self ->_appCheck getLimitedUseTokenWithCompletion: ^(GACAppCheckToken * _Nullable token,
635661 NSError * _Nullable error) {
636- OIDAuthorizationRequest *request = nil ;
637662 if (token) {
638663 additionalParameters[kClientAssertionTypeParameter ] = kClientAssertionTypeParameterValue ;
639664 additionalParameters[kClientAssertionParameter ] = token.token ;
@@ -643,7 +668,7 @@ - (void)authorizationRequestWithOptions:(GIDSignInInternalOptions *)options comp
643668 NSLog (@" [Google Sign-In iOS]: Error retrieving App Check limited use token: %@ " , error);
644669 }
645670 #endif
646- request = [self authorizationRequestWithOptions: options
671+ OIDAuthorizationRequest * request = [self authorizationRequestWithOptions: options
647672 additionalParameters: additionalParameters];
648673 if (self->_timedLoader .animationStatus == GIDTimedLoaderAnimationStatusAnimating) {
649674 [self ->_timedLoader stopTimingWithCompletion: ^{
@@ -667,13 +692,23 @@ - (void)authorizationRequestWithOptions:(GIDSignInInternalOptions *)options comp
667692- (OIDAuthorizationRequest *)
668693 authorizationRequestWithOptions:(GIDSignInInternalOptions *)options
669694 additionalParameters : (NSDictionary <NSString *, NSString *> *)additionalParameters {
670- OIDAuthorizationRequest *request =
671- [[OIDAuthorizationRequest alloc ] initWithConfiguration: _appAuthConfiguration
672- clientId: options.configuration.clientID
673- scopes: options.scopes
674- redirectURL: [self redirectURLWithOptions: options]
675- responseType: OIDResponseTypeCode
676- additionalParameters: additionalParameters];
695+ OIDAuthorizationRequest *request;
696+ if (options.nonce ) {
697+ request = [[OIDAuthorizationRequest alloc ] initWithConfiguration: _appAuthConfiguration
698+ clientId: options.configuration.clientID
699+ scopes: options.scopes
700+ redirectURL: [self redirectURLWithOptions: options]
701+ responseType: OIDResponseTypeCode
702+ nonce: options.nonce
703+ additionalParameters: additionalParameters];
704+ } else {
705+ request = [[OIDAuthorizationRequest alloc ] initWithConfiguration: _appAuthConfiguration
706+ clientId: options.configuration.clientID
707+ scopes: options.scopes
708+ redirectURL: [self redirectURLWithOptions: options]
709+ responseType: OIDResponseTypeCode
710+ additionalParameters: additionalParameters];
711+ }
677712 return request;
678713}
679714
@@ -724,7 +759,7 @@ - (NSURL *)redirectURLWithOptions:(GIDSignInInternalOptions *)options {
724759
725760- (void )processAuthorizationResponse : (nullable OIDAuthorizationResponse *)authorizationResponse
726761 error : (nullable NSError *)error
727- emmSupport : (NSString *)emmSupport {
762+ emmSupport : (NSString *)emmSupport {
728763 if (_restarting) {
729764 // The auth flow is restarting, so the work here would be performed in the next round.
730765 _restarting = NO ;
0 commit comments