Google Sign-In for iOS Does Not Save Authentication Information to Keychain When Scopes Are Added

Asked 2 years ago, Updated 2 years ago, 76 views

I have deployed Google Sign-In for iOS (Google/SignIn) on CocoaPods, but when I add a scope, the information does not appear to be registered in keyChain.

Assumptions
Please refer to the following site to add processing such as delete.
https://developers.google.com/identity/sign-in/ios/start

How it works
1.Sign In processing with code from within the application.
Each Sign In process with or without additional scope is as follows:

1-1 If you do not want to add a scope

[GIDSignInsharedInstance] signIn;

1-2 Adding Scopes

NSString*tasksScope=@"https://www.googleapis.com/auth/tasks";
NSSstring* calendarScope=@"https://www.googleapis.com/auth/calendar";
NSArray*currentScopes=[GIDSignInsharedInstance].scopes;

NNSArray* additionalScopes= [NSArray arrayWithObjects: tasksScope, calendarScope, nil];

GIDSignInsharedInstance.scopes=[currentScopes arrayByAddingObjectsFromArray:additionalScopes];

[GIDSignInsharedInstance] signIn;

2. Exit the app (Double tap home button & swipe up to drop the app)

3. Re-launch the app and use the following methods to check the storage status of the keychain

[GIDSignInsharedInstance].hasAuthInKeychain

This behavior returns YES if you do not want to add a scope, or NO if you do.

In this case, it seems that every time you hit the API, the user authenticates.
Is there any way to save authentication information in the keychain even if I add a scope?(Something is missing, etc.)

I tried to save the authentication information myself, but I stopped because I thought I couldn't implement it because I didn't get the "client_secret" to use when refreshing tokens.

Also, there may be separate libraries for Google Tasks and Calendar, but when installing with CocoaPods, it seems that the Swift library cannot be installed properly (using use_frameworks!), so we have stopped this direction.

The environment for performing the operational verification is as follows:
iOS 9.3 (Simulator Boot)
XCode Version 7.3

I would appreciate your feedback.

swift ios objective-c

2022-09-30 17:32

1 Answers

Try setting scopes before hasAuthInKeychain.


2022-09-30 17:32

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.