Ensure additionalTokenRefreshParametersForAuthSession returns a string dictionary#559
Closed
Ensure additionalTokenRefreshParametersForAuthSession returns a string dictionary#559
additionalTokenRefreshParametersForAuthSession returns a string dictionary#559Conversation
…onary of type <NSString *,NSString *>.
Closed
additionalTokenRefreshParametersForAuthSession returns a string dictionary
mdmathias
reviewed
Oct 2, 2025
GoogleSignIn/Sources/GIDEMMSupport.m
Outdated
| NSMutableDictionary<NSString *, NSString *> *convertedParameters = | ||
| [NSMutableDictionary dictionary]; | ||
| [originalParameters enumerateKeysAndObjectsUsingBlock:^(NSString *key, id value, BOOL *stop) { | ||
| if ([value isKindOfClass:[NSNumber class]]) { |
Collaborator
There was a problem hiding this comment.
I think we want to be a bit more complete than checking for an NSNumber. We can leverage NSJSONSerialization to help us out.
- Turn the
originalParametersdictionary into data via +[NSJSONSerialization dataWithJSONObject:options:error:] - Take that
NSDataand make anNSStringfrom it: -[NSString initWithData:encoding:] - Now that you have a string dictionary, make that
NSDatavia [-[NSString dataUsingEncoding:] - Pass that
NSDatato +[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.
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
GIDEMMSupportand makes the Google Sign-In library more robust by:enumerateKeysAndObjectsUsingBlock:instance methodNSNumbervalues toNSStringThis ensures that the dictionary returned to GTMAppAuth is always of the correct type.