0
votes

I am implementing Google Calendar API into my iOS application following the code in this link

https://developers.google.com/google-apps/calendar/quickstart/ios?ver=swift

There is a note at the bottom of the page that said the following :

"Authorization information is stored in your Keychain, so subsequent executions will not prompt for authorization."

However, it is asking the user to sign in every time you lunch the application so it is not stored in the keychain. My question is how do I store the credentials of the user properly ion the keychain so it will not ask for the user to sign in every single time we open the application?

1

1 Answers

1
votes

Yes, that's correct. If you're not properly saving the token, the user will have to sign in again the next time the application is run.

Here is how you should resolve this issue:

kKeychainItemName - is used to save the token on the user’s keychain

Code snippet:

  // Display the authentication view
  GTMOAuth2ViewControllerTouch *viewController;
  viewController = [[[GTMOAuth2ViewControllerTouch alloc] initWithAuthentication:auth
        authorizationURL:authURL
        keychainItemName:kKeychainItemName
               ...
      finishedSelector:@selector(viewController:finishedWithAuth:error:)] autorelease];

There is more information from Google Github page. Hope this helps and Good Luck!