Since the flutter team has added google_sign_in_macos to their repo this is no longer maintained. Please use google_sign_in_ios.
The osx implementation of [google_sign_in
][1].
- First register your application.
- Make sure the file you download in step 1 is named
GoogleService-Info.plist
. - Move or copy
GoogleService-Info.plist
into the[my_project]/macos/Runner
directory. - Open Xcode, then right-click on
Runner
directory and selectAdd Files to "Runner"
. - Select
GoogleService-Info.plist
from the file manager. - A dialog will show up and ask you to select the targets, select the
Runner
target. - If you need to authenticate to a backend server you can add a
SERVER_CLIENT_ID
key value pair in yourGoogleService-Info.plist
.<key>SERVER_CLIENT_ID</key> <string>[YOUR SERVER CLIENT ID]</string>
- Then add the
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 -->
- Required for Mac. Add the
com.google.GIDSignIn
Keychain sharing into theSigning & Capabilities -> Keychain Sharing
.
As an alternative to adding GoogleService-Info.plist
to your Xcode project,
you can instead configure your app in Dart code. In this case, skip steps 3 to 7
and pass clientId
and serverClientId
to the GoogleSignIn
constructor:
GoogleSignIn _googleSignIn = GoogleSignIn(
...
// The OAuth client id of your app. This is required.
clientId: ...,
// If you need to authenticate to a backend server, specify its OAuth client. This is optional.
serverClientId: ...,
);
Note that step 8 and 9 are still required.