Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit de07fd2

Browse files
committed
Inject contextProvider in getURL(...) method
This is the first step of no longer requiring `NewGoogleAuthenticator` to store the `contextProvider`.
1 parent c0d1606 commit de07fd2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

WordPressAuthenticator/GoogleSignIn/NewGoogleAuthenticator.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,16 @@ public class NewGoogleAuthenticator: NSObject {
5858
/// Get the user's OAuth token from their Google account. This token can be used to authenticate with the WordPress backend.
5959
public func getOAuthToken() async throws -> IDToken {
6060
let pkce = try ProofKeyForCodeExchange()
61-
let url = try await getURL(clientId: clientId, scheme: scheme, pkce: pkce)
61+
let url = try await getURL(clientId: clientId, scheme: scheme, pkce: pkce, contextProvider: contextProvider)
6262
return try await requestOAuthToken(url: url, clientId: clientId, audience: audience, pkce: pkce)
6363
}
6464

65-
func getURL(clientId: GoogleClientId, scheme: String, pkce: ProofKeyForCodeExchange) async throws -> URL {
65+
func getURL(
66+
clientId: GoogleClientId,
67+
scheme: String,
68+
pkce: ProofKeyForCodeExchange,
69+
contextProvider: ASWebAuthenticationPresentationContextProviding
70+
) async throws -> URL {
6671
let url = try URL.googleSignInAuthURL(clientId: clientId, pkce: pkce)
6772
return try await withCheckedThrowingContinuation { continuation in
6873
let session = ASWebAuthenticationSession(

0 commit comments

Comments
 (0)