Skip to content

[google_sign_in_ios] Upgrade GoogleSignIn iOS SDK to 7.0 #5240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/google_sign_in/google_sign_in/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 6.1.6

* Updates README to direct to google_sign_in_ios README for iOS integration instructions.

## 6.1.5

* Adds pub topics to package metadata.
Expand Down
58 changes: 3 additions & 55 deletions packages/google_sign_in/google_sign_in/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,59 +27,7 @@ Otherwise, you may encounter `APIException` errors.

### iOS integration

1. [First register your application](https://firebase.google.com/docs/ios/setup).
2. Make sure the file you download in step 1 is named
`GoogleService-Info.plist`.
3. Move or copy `GoogleService-Info.plist` into the `[my_project]/ios/Runner`
directory.
4. Open Xcode, then right-click on `Runner` directory and select
`Add Files to "Runner"`.
5. Select `GoogleService-Info.plist` from the file manager.
6. A dialog will show up and ask you to select the targets, select the `Runner`
target.
7. If you need to authenticate to a backend server you can add a
`SERVER_CLIENT_ID` key value pair in your `GoogleService-Info.plist`.
```xml
<key>SERVER_CLIENT_ID</key>
<string>[YOUR SERVER CLIENT ID]</string>
```
8. Then add the `CFBundleURLTypes` attributes below into the
`[my_project]/ios/Runner/Info.plist` file.

```xml
<!-- 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 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:

```dart
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 is still required.
Please see [instructions on integrating Google Sign-In for iOS](https://pub.dev/packages/google_sign_in_ios#ios-integration).

#### iOS additional requirement

Expand Down Expand Up @@ -212,12 +160,12 @@ For more details, take a look at the

### Does an app always need to check `canAccessScopes`?

The new web SDK implicitly grant access to the `email`, `profile` and `openid`
The new web SDK implicitly grant access to the `email`, `profile` and `openid`
scopes when users complete the sign-in process (either via the One Tap UX or the
Google Sign In button).

If an app only needs an `idToken`, or only requests permissions to any/all of
the three scopes mentioned above
the three scopes mentioned above
([OpenID Connect scopes](https://developers.google.com/identity/protocols/oauth2/scopes#openid-connect)),
it won't need to implement any additional scope handling.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

/* Begin PBXBuildFile section */
5C6F5A6E1EC3B4CB008D64B5 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 5C6F5A6D1EC3B4CB008D64B5 /* GeneratedPluginRegistrant.m */; };
7A303C2E1E89D76400B1F19E /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7A303C2D1E89D76400B1F19E /* GoogleService-Info.plist */; };
7ACDFB0E1E8944C400BE2D00 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7ACDFB0D1E8944C400BE2D00 /* AppFrameworkInfo.plist */; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
Expand Down Expand Up @@ -39,7 +38,6 @@
5A76713E622F06379AEDEBFA /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
5C6F5A6C1EC3B4CB008D64B5 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
5C6F5A6D1EC3B4CB008D64B5 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
7A303C2D1E89D76400B1F19E /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
7ACDFB0D1E8944C400BE2D00 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -118,7 +116,6 @@
97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */,
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
7A303C2D1E89D76400B1F19E /* GoogleService-Info.plist */,
97C147021CF9000F007C117D /* Info.plist */,
97C146F11CF9000F007C117D /* Supporting Files */,
);
Expand Down Expand Up @@ -173,7 +170,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "The Flutter Authors";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -204,7 +201,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7A303C2E1E89D76400B1F19E /* GoogleService-Info.plist in Resources */,
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
7ACDFB0E1E8944C400BE2D00 /* AppFrameworkInfo.plist in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,9 @@
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>GIDClientID</key>
<string>479882132969-9i9aqik3jfjd7qhci1nqf0bm2g71rm1u.apps.googleusercontent.com</string>
<key>GIDServerClientID</key>
<string>YOUR_SERVER_CLIENT_ID</string>
</dict>
</plist>
5 changes: 3 additions & 2 deletions packages/google_sign_in/google_sign_in/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for Google Sign-In, a secure authentication system
for signing in with a Google account on Android and iOS.
repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
version: 6.1.5
version: 6.1.6

environment:
sdk: ">=2.19.0 <4.0.0"
Expand Down Expand Up @@ -43,5 +43,6 @@ topics:
# The example deliberately includes limited-use secrets.
false_secrets:
- /example/android/app/google-services.json
- /example/ios/Runner/GoogleService-Info.plist
- /example/ios/Runner/Info.plist
- /example/ios/RunnerTests/GoogleService-Info.plist
- /example/ios/RunnerTests/GoogleSignInTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,28 @@ void main() {
verify(mockPlatform.signIn());
});

test(
'clientId and serverClientId parameters is forwarded to implementation',
() async {
// #docregion GoogleSignIn
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',
);
// #enddocregion GoogleSignIn

await googleSignIn.signIn();

_verifyInit(
mockPlatform,
clientId: 'Your Client ID',
serverClientId: 'Your Server ID',
);
verify(mockPlatform.signIn());
});

test('forceCodeForRefreshToken sent with init method call', () async {
final GoogleSignIn googleSignIn =
GoogleSignIn(forceCodeForRefreshToken: true);
Expand Down
4 changes: 4 additions & 0 deletions packages/google_sign_in/google_sign_in_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 5.6.5

* Upgrades GoogleSignIn iOS SDK to 7.0.

## 5.6.4

* Converts platform communication to Pigeon.
Expand Down
59 changes: 59 additions & 0 deletions packages/google_sign_in/google_sign_in_ios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,62 @@ should add it to your `pubspec.yaml` as usual.

[1]: https://pub.dev/packages/google_sign_in
[2]: https://flutter.dev/docs/development/packages-and-plugins/developing-packages#endorsed-federated-plugin

### iOS integration

1. [Create a Firebase project](https://firebase.google.com/docs/ios/setup#create-firebase-project)
and [register your application](https://firebase.google.com/docs/ios/setup#register-app).
2. [Enable Google Sign-In for your Firebase project](https://firebase.google.com/docs/auth/ios/google-signin#enable_google_sign-in_for_your_firebase_project).
3. Make sure to download a new copy of your project's
`GoogleService-Info.plist` from step 2. Do not put this file in your project.
4. Add the client ID from the `GoogleService-Info.plist` into your app's
`[my_project]/ios/Runner/Info.plist` file.
```xml
<key>GIDClientID</key>
<!-- TODO Replace this value: -->
<!-- Copied from GoogleService-Info.plist key CLIENT_ID -->
<string>[YOUR IOS CLIENT ID]</string>
```
5. If you need to authenticate to a backend server you can add a
`GIDServerClientID` key value pair in your `[my_project]/ios/Runner/Info.plist` file.
```xml
<key>GIDServerClientID</key>
<string>[YOUR SERVER CLIENT ID]</string>
```
6. Then add the `CFBundleURLTypes` attributes below into the
`[my_project]/ios/Runner/Info.plist` file.

```xml
<!-- 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:

<?code-excerpt "../google_sign_in/test/google_sign_in_test.dart (GoogleSignIn)"?>
```dart
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.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/* Begin PBXBuildFile section */
5C6F5A6E1EC3B4CB008D64B5 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 5C6F5A6D1EC3B4CB008D64B5 /* GeneratedPluginRegistrant.m */; };
7A303C2E1E89D76400B1F19E /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7A303C2D1E89D76400B1F19E /* GoogleService-Info.plist */; };
78A36DA12AF5761E00CBFD43 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7A303C2D1E89D76400B1F19E /* GoogleService-Info.plist */; };
7ACDFB0E1E8944C400BE2D00 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7ACDFB0D1E8944C400BE2D00 /* AppFrameworkInfo.plist */; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
Expand Down Expand Up @@ -163,7 +163,6 @@
97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */,
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
7A303C2D1E89D76400B1F19E /* GoogleService-Info.plist */,
97C147021CF9000F007C117D /* Info.plist */,
97C146F11CF9000F007C117D /* Supporting Files */,
);
Expand Down Expand Up @@ -191,6 +190,7 @@
isa = PBXGroup;
children = (
F76AC1A42666D0540040C8BC /* GoogleSignInTests.m */,
7A303C2D1E89D76400B1F19E /* GoogleService-Info.plist */,
F76AC1A62666D0540040C8BC /* Info.plist */,
);
path = RunnerTests;
Expand Down Expand Up @@ -316,7 +316,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7A303C2E1E89D76400B1F19E /* GoogleService-Info.plist in Resources */,
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
7ACDFB0E1E8944C400BE2D00 /* AppFrameworkInfo.plist in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
Expand All @@ -328,6 +327,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
78A36DA12AF5761E00CBFD43 /* GoogleService-Info.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,9 @@
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>GIDClientID</key>
<string>479882132969-9i9aqik3jfjd7qhci1nqf0bm2g71rm1u.apps.googleusercontent.com</string>
<key>GIDServerClientID</key>
<string>YOUR_SERVER_CLIENT_ID</string>
</dict>
</plist>
Loading