Skip to content

GIDGoogleUser doesn't look like it will handle EMM support #304

Closed

Description

@mdmathias

Currently, GIDGoogleUser provides EMM error handling support by checking with itself if EMM support is provided (i.e., self.emmSupport). This call will notably occur before self.fetcherAuthorizer = authorization in the initializer.

The problem is that the implementation of -[GIDGoogleUser emmSupport] uses self.authState to determine EMM support. self.authState unfortunately, references fetcherAuthorizer.

Therefore, since GIDGoogleUser checks for EMM support prior to fetcherAuthorizer being set, it will always return nil when being checked.

- (OIDAuthState *) authState{
  return ((GTMAppAuthFetcherAuthorization *)self.fetcherAuthorizer).authState;
}

- (nullable NSString *)emmSupport {
  return self.authState.lastAuthorizationResponse
      .request.additionalParameters[kEMMSupportParameterName];
}

- (instancetype)initWithAuthState:(OIDAuthState *)authState
                      profileData:(nullable GIDProfileData *)profileData {
  self = [super init];
  if (self) {
    _tokenRefreshHandlerQueue = [[NSMutableArray alloc] init];
    _profile = profileData;
    
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
    GTMAppAuthFetcherAuthorization *authorization = self.emmSupport ?
        [[GIDAppAuthFetcherAuthorizationWithEMMSupport alloc] initWithAuthState:authState] :
        [[GTMAppAuthFetcherAuthorization alloc] initWithAuthState:authState];
#elif TARGET_OS_OSX || TARGET_OS_MACCATALYST
    GTMAppAuthFetcherAuthorization *authorization =
        [[GTMAppAuthFetcherAuthorization alloc] initWithAuthState:authState];
#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
    authorization.tokenRefreshDelegate = self;
    authorization.authState.stateChangeDelegate = self;
    self.fetcherAuthorizer = authorization;
    
    [self updateTokensWithAuthState:authState];
  }
  return self;
}

Activity

  1. added
    bugSomething isn't working
    triageIssues that need to be triaged
    on Apr 26, 2023
  2. self-assigned this
    on Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtriageIssues that need to be triaged

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions