The iOS and macOS implementation of google_sign_in.
This package is endorsed, which means you can simply use google_sign_in normally. This package will be automatically included in your app when you do, so you do not need to add it to your pubspec.yaml.
However, if you import this package to use any of its APIs directly, you should add it to your pubspec.yaml as usual.
The GoogleSignIn SDK requires keychain sharing to be enabled, by adding the following entitlements:
<key>keychain-access-groups</key> <array> <string>$(AppIdentifierPrefix)com.google.GIDSignIn</string> </array>
Without this step, the plugin will throw a keychain error PlatformException when trying to sign in.
GoogleService-Info.plist from step 2. Do not put this file in your project.GoogleService-Info.plist into your app's [my_project]/ios/Runner/Info.plist file.<key>GIDClientID</key> <!-- TODO Replace this value: --> <!-- Copied from GoogleService-Info.plist key CLIENT_ID --> <string>[YOUR IOS CLIENT ID]</string>
GIDServerClientID key value pair in your [my_project]/ios/Runner/Info.plist file.<key>GIDServerClientID</key> <string>[YOUR SERVER CLIENT ID]</string>
CFBundleURLTypes attributes below into the [my_project]/ios/Runner/Info.plist file.<!-- Put me in the [my_project]/ios/Runner/Info.plist file --> <!-- Google Sign-in Section --> <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleTypeRole</key> <string>Editor</string> <key>CFBundleURLSchemes</key> <array> <!-- TODO Replace this value: --> <!-- Copied from GoogleService-Info.plist key REVERSED_CLIENT_ID --> <string>com.googleusercontent.apps.861823949799-vc35cprkp249096uujjn0vvnmcvjppkn</string> </array> </dict> </array> <!-- End of the Google Sign-in Section -->
As an alternative to editing the Info.plist in your Xcode project, you can instead configure your app in Dart code. In this case, skip steps 4 to 5 and pass clientId and serverClientId to the GoogleSignIn constructor:
final GoogleSignIn googleSignIn = GoogleSignIn( // The OAuth client id of your app. This is required. clientId: 'Your Client ID', // If you need to authenticate to a backend server, specify its OAuth client. This is optional. serverClientId: 'Your Server ID', );
Note that step 6 is still required.