Skip to content

Commit 819e05b

Browse files
fix: twitter provider update to be pass through withTwitterSignIn()
1 parent 92e1453 commit 819e05b

File tree

2 files changed

+46
-6
lines changed

2 files changed

+46
-6
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2025 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
//
16+
// AuthService+Twitter.swift
17+
// FirebaseUI
18+
//
19+
// Created by Russell Wheatley on 01/05/2025.
20+
//
21+
22+
import FirebaseAuthSwiftUI
23+
24+
public extension AuthService {
25+
@discardableResult
26+
func withTwitterSignIn(provider _: [String]? = nil) -> AuthService {
27+
registerProvider(provider: TwitterProviderAuthUI())
28+
return self
29+
}
30+
}

FirebaseSwiftUI/FirebaseTwitterSwiftUI/Sources/Services/TwitterProviderAuthUI.swift

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ import FirebaseAuthSwiftUI
1717
import FirebaseCore
1818
import SwiftUI
1919

20-
public class TwitterProviderAuthUI: AuthProviderSwift, AuthProviderUI {
20+
public class TwitterProviderSwift: AuthProviderSwift {
21+
public let scopes: [String]
22+
let providerId = "twitter.com"
23+
24+
public init(scopes: [String] = ["user.readwrite"]) {
25+
self.scopes = scopes
26+
}
27+
2128
@MainActor public func createAuthCredential() async throws -> AuthCredential {
2229
let provider = OAuthProvider(providerID: providerId)
2330
return try await withCheckedThrowingContinuation { continuation in
@@ -35,19 +42,22 @@ public class TwitterProviderAuthUI: AuthProviderSwift, AuthProviderUI {
3542
}
3643
}
3744
}
45+
}
46+
47+
public class TwitterProviderAuthUI: TwitterProviderSwift, AuthProviderUI {
48+
public init() {
49+
super.init()
50+
}
3851

39-
public var provider: AuthProviderSwift { self }
4052
public let id: String = "twitter"
41-
let providerId = "twitter.com"
53+
public var provider: AuthProviderSwift { self }
4254

4355
@MainActor public func authButton() -> AnyView {
4456
AnyView(SignInWithTwitterButton())
4557
}
4658

47-
// TODO: need to implement delete user protocol
59+
// TODO: need to implement delete user protocol
4860
// @MainActor public func deleteUser(user _: User) async throws {
4961
// <#code#>
5062
// }
51-
52-
public init() {}
5363
}

0 commit comments

Comments
 (0)