Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions GoogleSignIn/Sources/GIDEMMSupport.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,21 @@ + (NSDictionary *)parametersWithParameters:(NSDictionary *)parameters

- (nullable NSDictionary<NSString *,NSString *> *)
additionalTokenRefreshParametersForAuthSession:(GTMAuthSession *)authSession {
return [GIDEMMSupport updatedEMMParametersWithParameters:
authSession.authState.lastTokenResponse.additionalParameters];
NSDictionary *originalParameters =
[GIDEMMSupport updatedEMMParametersWithParameters:authSession.authState.lastTokenResponse
.additionalParameters];

// Ensure returned dictionary has values of only type String.
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.

convertedParameters[key] = [value stringValue];
} else if ([value isKindOfClass:[NSString class]]) {
convertedParameters[key] = value;
}
}];
return convertedParameters;
}

- (void)updateErrorForAuthSession:(GTMAuthSession *)authSession
Expand Down