google / gtm-oauth2

Google Toolbox for Mac - OAuth 2 Controllers
Apache License 2.0
125 stars 70 forks source link

Pod 1.1.4 - "GTMOAuth2ErrorTokenUnavailable" Naming error #88

Closed mikezucc closed 7 years ago

mikezucc commented 7 years ago

for pod 1.1.4, GTMOAuth2ErrorTokenUnavailable is used instead of kGTMOAuth2ErrorTokenUnavailable. Anyone else get this build error? Something seems off with the pod, because if I manually resolve this a linker error shows up later on for a misnamed selector

thomasvl commented 7 years ago

The constant doesn't have a k on the front: https://github.com/google/gtm-oauth2/blob/master/Source/GTMOAuth2Authentication.h#L102.

The one with the k is a #define - https://github.com/google/gtm-oauth2/blob/master/Source/GTMOAuth2Authentication.h#L110

mikezucc commented 7 years ago

The build fails in this function:

+ (BOOL)saveParamsToKeychainForName:(NSString *)keychainItemName
                      accessibility:(CFTypeRef)accessibility
                     authentication:(GTMOAuth2Authentication *)auth
                              error:(NSError **)error
  [self removeAuthFromKeychainForName:keychainItemName];
  // don't save unless we have a token that can really authorize requests
  if (![auth canAuthorize]) {
    if (error) {
      *error = [NSError errorWithDomain:kGTMOAuth2ErrorDomain
                                   code:GTMOAuth2ErrorTokenUnavailable
                               userInfo:nil];
    }
    return NO;
  }

  if (accessibility == NULL) {
    accessibility = kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly;
  }

  // make a response string containing the values we want to save
  NSString *password = [auth persistenceResponseString];
  GTMOAuth2Keychain *keychain = [GTMOAuth2Keychain defaultKeychain];
  return [keychain setPassword:password
                    forService:keychainItemName
                 accessibility:accessibility
                       account:kGTMOAuth2AccountName
                         error:error];
}

Exact error: Use of undeclared identifier GTMOAuth2ErrorTokenUnavailable

mikezucc commented 7 years ago

Also, my version of that header is

enum {
  // Error code indicating that the window was prematurely closed
  kGTMOAuth2ErrorWindowClosed          = -1000,
  kGTMOAuth2ErrorAuthorizationFailed   = -1001,
  kGTMOAuth2ErrorTokenExpired          = -1002,
  kGTMOAuth2ErrorTokenUnavailable      = -1003,
  kGTMOAuth2ErrorUnauthorizableRequest = -1004
};
mikezucc commented 7 years ago

Ah it seems that a pod is using GTM 1.0, not 1.1.4. I'm guessing the version of the header is 1.0

mikezucc commented 7 years ago

https://cocoapods.org/pods/GoogleSignIn

thomasvl commented 7 years ago

Sounds like something is causing a mix of versions then? You'll probably want to reach out to them about the making sure they can use 1.1.x also.

mikezucc commented 7 years ago

Yep I'll send an email to Google. thanks for quick response 👍

mikezucc commented 7 years ago

You can close this as not an issue

thomasvl commented 7 years ago

Actually, are they shipping copies of these headers? Maybe that's where the mixup comes, you get one dep on this pod which is 1.1.x, and they ship a copy of the older headers and the header search path decides what gets found.

mikezucc commented 7 years ago

Actually, I was doubly wrong, we had a lingering dependency from the original google plus ios sdk days where they shipped with copies of the old frameworks. false alarm :]