google / gtm-oauth2

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

authorizeFromKeychainForName: API calls fails in mac app extension. #94

Closed praveencastelino closed 7 years ago

praveencastelino commented 7 years ago

I have a Mac app and extension. The app does the login and internally the google SDK saves the information in user defaults.

The api call API authorizeFromKeychainForName: return NO in extension due to the information stored in user defaults is not accessible in the extension.

// before accessing the keychain, check preferences to verify that we've // previously saved a token to the keychain (so we don't needlessly raise // a keychain access permission dialog) NSString *prefKey = [self prefsKeyForName:keychainItemName]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; BOOL flag = [defaults boolForKey:prefKey]; if (!flag) { return NO; } Since the app and extensions have their own set of UserDefaults, the above code fails.

thomasvl commented 7 years ago

I haven't looked at macOS extensions, but my guess is it will be something like iOS extensions, where you might need to use share groups to allow the extension and App both to use the same info.

praveencastelino commented 7 years ago

yup..that's true. That's how we are sharing the data between extension and mac app.

Since the SDK uses NSUserDefaults to store the data and the user default is not accessible between extension and App, the condition in the SDK fails.

praveencastelino commented 7 years ago

Closing this issue as this SDK is deprecated...We are using now GTMAppAuth