Skip to content

Conversation

@brnnmrls
Copy link
Member

@brnnmrls brnnmrls commented Oct 1, 2025

This PR addresses a runtime crash that occurs when the dictionary returned by additionalTokenRefreshParametersForAuthSession: contains non-string values, leading to a type mismatch in GTMAppAuth.

This fix is implemented in GIDEMMSupport and makes the Google Sign-In library more robust by:

  • Iterating through the additionalParameters dictionary using the enumerateKeysAndObjectsUsingBlock: instance method
  • Checking the type of each value and explicitly converting NSNumber values to NSString
  • Safely ignoring any other non-string types to prevent future crashes.

This ensures that the dictionary returned to GTMAppAuth is always of the correct type.

@brnnmrls brnnmrls self-assigned this Oct 1, 2025
@brnnmrls brnnmrls linked an issue Oct 1, 2025 that may be closed by this pull request
@brnnmrls brnnmrls requested review from mdmathias and yalkhder October 1, 2025 21:34
@brnnmrls brnnmrls marked this pull request as ready for review October 1, 2025 21:34
@brnnmrls brnnmrls changed the title Ensure `additionalTokenRefreshParametersForAuthSession1 returns a string dictionary Ensure additionalTokenRefreshParametersForAuthSession returns a string dictionary Oct 2, 2025
NSMutableDictionary<NSString *, NSString *> *convertedParameters =
[NSMutableDictionary dictionary];
[originalParameters enumerateKeysAndObjectsUsingBlock:^(NSString *key, id value, BOOL *stop) {
if ([value isKindOfClass:[NSNumber class]]) {
Copy link
Collaborator

@mdmathias mdmathias Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to be a bit more complete than checking for an NSNumber. We can leverage NSJSONSerialization to help us out.

  1. Turn the originalParameters dictionary into data via +[NSJSONSerialization dataWithJSONObject:options:error:]
  2. Take that NSData and make an NSString from it: -[NSString initWithData:encoding:]
  3. Now that you have a string dictionary, make that NSData via [-[NSString dataUsingEncoding:]
  4. Pass that NSData to +[NSJSONSerialization JSONObjectWithData:options:error:]

The resulting JSON object should be a NSDictionary<NSString *, NSString *> *. The idea behind step 2 is that it should make everything in the NSData an NSString.

I recommend writing some unit tests with various flavors of types in the values of originalParameters.

@brnnmrls brnnmrls closed this Oct 20, 2025
@Aloisius Aloisius mentioned this pull request Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Login request crash

2 participants