Skip to content

Commit 14368a9

Browse files
committed
Cleanup.
1 parent 0f00694 commit 14368a9

File tree

4 files changed

+21
-33
lines changed

4 files changed

+21
-33
lines changed

Samples/Swift/DaysUntilBirthday/DaysUntilBirthday.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@
602602
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
603603
CODE_SIGN_STYLE = Automatic;
604604
CURRENT_PROJECT_VERSION = 1;
605+
EMAIL_SECRET = petea.test;
605606
GCC_PREPROCESSOR_DEFINITIONS = (
606607
"$(inherited)",
607608
"DEBUG=1",
@@ -615,6 +616,7 @@
615616
"@loader_path/Frameworks",
616617
);
617618
MARKETING_VERSION = 1.0;
619+
PASSWORD_SECRET = tset.aetep;
618620
PRODUCT_BUNDLE_IDENTIFIER = "com.google.DaysUntilBirthdayUITests-iOS-";
619621
PRODUCT_NAME = "$(TARGET_NAME)";
620622
PROVISIONING_PROFILE = "";
@@ -631,6 +633,7 @@
631633
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
632634
CODE_SIGN_STYLE = Automatic;
633635
CURRENT_PROJECT_VERSION = 1;
636+
EMAIL_SECRET = petea.test;
634637
GCC_PREPROCESSOR_DEFINITIONS = "";
635638
GENERATE_INFOPLIST_FILE = YES;
636639
INFOPLIST_KEY_LSApplicationCategoryType = "";
@@ -641,6 +644,7 @@
641644
"@loader_path/Frameworks",
642645
);
643646
MARKETING_VERSION = 1.0;
647+
PASSWORD_SECRET = tset.aetep;
644648
PRODUCT_BUNDLE_IDENTIFIER = "com.google.DaysUntilBirthdayUITests-iOS-";
645649
PRODUCT_NAME = "$(TARGET_NAME)";
646650
PROVISIONING_PROFILE = "";

Samples/Swift/DaysUntilBirthday/Shared/Services/BirthdayLoader.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,6 @@ final class BirthdayLoader {
3838
return URLRequest(url: url)
3939
}()
4040

41-
private lazy var session: URLSession? = {
42-
guard let accessToken = GIDSignIn
43-
.sharedInstance
44-
.currentUser?
45-
.accessToken
46-
.tokenString else { return nil }
47-
let configuration = URLSessionConfiguration.default
48-
configuration.httpAdditionalHeaders = [
49-
"Authorization": "Bearer \(accessToken)"
50-
]
51-
return URLSession(configuration: configuration)
52-
}()
53-
5441
private func sessionWithFreshToken() async throws -> URLSession {
5542
guard let user = GIDSignIn.sharedInstance.currentUser else {
5643
throw Error.noCurrentUserForSessionWithFreshToken

Samples/Swift/DaysUntilBirthday/Shared/Services/GoogleSignInAuthenticator.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,25 @@ final class GoogleSignInAuthenticator {
3333
}
3434

3535

36-
#if os(iOS)
36+
#if os(iOS)
3737
/// Signs in the user based upon the selected account.
3838
/// - parameter rootViewController: The `UIViewController` to use during the sign in flow.
39-
/// - returns: The signed in `GIDGoogleUser`.
39+
/// - returns: The resulting`GIDUserAuth`.
4040
/// - throws: Any error that may arise during the sign in process.
4141
func signIn(with rootViewController: UIViewController) async throws -> GIDUserAuth {
4242
return try await GIDSignIn.sharedInstance.signIn(withPresenting: rootViewController)
4343
}
44-
#endif
44+
#endif
4545

46-
#if os(macOS)
46+
#if os(macOS)
4747
/// Signs in the user based upon the selected account.
4848
/// - parameter window: The `NSWindow` to use during the sign in flow.
49-
/// - returns: The signed in `GIDGoogleUser`.
49+
/// - returns: The resulting`GIDUserAuth`.
5050
/// - throws: Any error that may arise during the sign in process.
5151
func signIn(with window: NSWindow) async throws -> GIDUserAuth {
5252
return try await GIDSignIn.sharedInstance.signIn(withPresenting: window)
5353
}
54-
#endif
54+
#endif
5555

5656
/// Signs out the current user.
5757
func signOut() {
@@ -67,7 +67,7 @@ final class GoogleSignInAuthenticator {
6767
#if os(iOS)
6868
/// Adds the birthday read scope for the current user.
6969
/// - parameter viewController: The `UIViewController` to use while authorizing the scope.
70-
/// - returns: The `GIDGoogleUser` with the authorized scope.
70+
/// - returns: The resulting`GIDUserAuth`.
7171
/// - throws: Any error that may arise while authorizing the scope.
7272
func addBirthdayReadScope(viewController: UIViewController) async throws -> GIDUserAuth {
7373
guard let currentUser = GIDSignIn.sharedInstance.currentUser else {
@@ -83,7 +83,7 @@ final class GoogleSignInAuthenticator {
8383
#if os(macOS)
8484
/// Adds the birthday read scope for the current user.
8585
/// - parameter window: The `NSWindow` to use while authorizing the scope.
86-
/// - returns: The `GIDGoogleUser` with the authorized scope.
86+
/// - returns: The resulting`GIDUserAuth`.
8787
/// - throws: Any error that may arise while authorizing the scope.
8888
func addBirthdayReadScope(window: NSWindow) async throws -> GIDUserAuth {
8989
guard let currentUser = GIDSignIn.sharedInstance.currentUser else {

Samples/Swift/DaysUntilBirthday/Shared/ViewModels/AuthenticationViewModel.swift

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,30 +52,26 @@ final class AuthenticationViewModel: ObservableObject {
5252
print("There is no root view controller!")
5353
return
5454
}
55-
56-
Task { @MainActor in
57-
do {
58-
let userAuth = try await authenticator.signIn(with: rootViewController)
59-
self.state = .signedIn(userAuth.user)
60-
} catch {
61-
print("Error signing in: \(error)")
62-
}
63-
}
6455
#elseif os(macOS)
6556
guard let presentingWindow = NSApplication.shared.windows.first else {
6657
print("There is no presenting window!")
6758
return
6859
}
60+
#endif
6961

7062
Task { @MainActor in
7163
do {
64+
65+
#if os(iOS)
66+
let userAuth = try await authenticator.signIn(with: rootViewController)
67+
#elseif os(macOS)
7268
let userAuth = try await authenticator.signIn(with: presentingWindow)
69+
#endif
7370
self.state = .signedIn(userAuth.user)
7471
} catch {
7572
print("Error signing in: \(error)")
7673
}
7774
}
78-
#endif
7975
}
8076

8177
/// Signs the user out.
@@ -102,17 +98,18 @@ final class AuthenticationViewModel: ObservableObject {
10298
#if os(iOS)
10399
/// Adds the requested birthday read scope.
104100
/// - parameter viewController: A `UIViewController` to use while presenting the flow.
105-
/// - returns: A `GIDGoogleUser` with the authorized scope.
101+
/// - returns: The resulting`GIDUserAuth`.
106102
/// - throws: Any error that may arise while adding the read birthday scope.
107103
func addBirthdayReadScope(viewController: UIViewController) async throws -> GIDUserAuth {
108104
return try await authenticator.addBirthdayReadScope(viewController: viewController)
109105
}
110106
#endif
111107

108+
112109
#if os(macOS)
113110
/// adds the requested birthday read scope.
114111
/// - parameter window: An `NSWindow` to use while presenting the flow.
115-
/// - returns: A `GIDGoogleUser` with the authorized scope.
112+
/// - returns: The resulting `GIDUserAuth`.
116113
/// - throws: Any error that may arise while adding the read birthday scope.
117114
func addBirthdayReadScope(window: NSWindow) async throws -> GIDUserAuth {
118115
return try await authenticator.addBirthdayReadScope(window: window)

0 commit comments

Comments
 (0)