File tree Expand file tree Collapse file tree 2 files changed +46
-6
lines changed
Expand file tree Collapse file tree 2 files changed +46
-6
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change @@ -17,7 +17,14 @@ import FirebaseAuthSwiftUI
1717import FirebaseCore
1818import 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}
You can’t perform that action at this time.
0 commit comments