aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firebase/Auth/Source/AuthProviders
diff options
context:
space:
mode:
Diffstat (limited to 'Firebase/Auth/Source/AuthProviders')
-rw-r--r--Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailAuthProvider.h63
-rw-r--r--Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailAuthProvider.m35
-rw-r--r--Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailPasswordAuthCredential.h48
-rw-r--r--Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailPasswordAuthCredential.m51
-rw-r--r--Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailPasswordAuthProvider.h49
-rw-r--r--Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailPasswordAuthProvider.m35
-rw-r--r--Firebase/Auth/Source/AuthProviders/Facebook/FIRFacebookAuthCredential.h36
-rw-r--r--Firebase/Auth/Source/AuthProviders/Facebook/FIRFacebookAuthCredential.m51
-rw-r--r--Firebase/Auth/Source/AuthProviders/Facebook/FIRFacebookAuthProvider.h51
-rw-r--r--Firebase/Auth/Source/AuthProviders/Facebook/FIRFacebookAuthProvider.m36
-rw-r--r--Firebase/Auth/Source/AuthProviders/GitHub/FIRGitHubAuthCredential.h41
-rw-r--r--Firebase/Auth/Source/AuthProviders/GitHub/FIRGitHubAuthCredential.m49
-rw-r--r--Firebase/Auth/Source/AuthProviders/GitHub/FIRGitHubAuthProvider.h51
-rw-r--r--Firebase/Auth/Source/AuthProviders/GitHub/FIRGitHubAuthProvider.m36
-rw-r--r--Firebase/Auth/Source/AuthProviders/Google/FIRGoogleAuthCredential.h38
-rw-r--r--Firebase/Auth/Source/AuthProviders/Google/FIRGoogleAuthCredential.m54
-rw-r--r--Firebase/Auth/Source/AuthProviders/Google/FIRGoogleAuthProvider.h53
-rw-r--r--Firebase/Auth/Source/AuthProviders/Google/FIRGoogleAuthProvider.m37
-rw-r--r--Firebase/Auth/Source/AuthProviders/OAuth/FIROAuthCredential.h55
-rw-r--r--Firebase/Auth/Source/AuthProviders/OAuth/FIROAuthCredential.m50
-rw-r--r--Firebase/Auth/Source/AuthProviders/OAuth/FIROAuthProvider.h64
-rw-r--r--Firebase/Auth/Source/AuthProviders/OAuth/FIROAuthProvider.m42
-rw-r--r--Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthCredential.h37
-rw-r--r--Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthCredential.m65
-rw-r--r--Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthCredential_Internal.h70
-rw-r--r--Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthProvider.h90
-rw-r--r--Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthProvider.m213
-rw-r--r--Firebase/Auth/Source/AuthProviders/Phone/NSString+FIRAuth.h36
-rw-r--r--Firebase/Auth/Source/AuthProviders/Phone/NSString+FIRAuth.m36
-rw-r--r--Firebase/Auth/Source/AuthProviders/Twitter/FIRTwitterAuthCredential.h48
-rw-r--r--Firebase/Auth/Source/AuthProviders/Twitter/FIRTwitterAuthCredential.m51
-rw-r--r--Firebase/Auth/Source/AuthProviders/Twitter/FIRTwitterAuthProvider.h52
-rw-r--r--Firebase/Auth/Source/AuthProviders/Twitter/FIRTwitterAuthProvider.m36
33 files changed, 1759 insertions, 0 deletions
diff --git a/Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailAuthProvider.h b/Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailAuthProvider.h
new file mode 100644
index 0000000..4fb5ea0
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailAuthProvider.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "FIRAuthSwiftNameSupport.h"
+
+@class FIRAuthCredential;
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ @brief A string constant identifying the email & password identity provider.
+ */
+extern NSString *const FIREmailAuthProviderID FIR_SWIFT_NAME(EmailAuthProviderID);
+
+/**
+ @brief please use @c FIREmailAuthProviderID instead.
+ */
+extern NSString *const FIREmailPasswordAuthProviderID __attribute__((deprecated));
+
+/** @class FIREmailAuthProvider
+ @brief A concrete implementation of @c FIRAuthProvider for Email & Password Sign In.
+ */
+FIR_SWIFT_NAME(EmailAuthProvider)
+@interface FIREmailAuthProvider : NSObject
+
+/** @typedef FIREmailPasswordAuthProvider
+ @brief Please use @c FIREmailAuthProvider instead.
+ */
+typedef FIREmailAuthProvider FIREmailPasswordAuthProvider __attribute__((deprecated));
+
+
+/** @fn credentialWithEmail:password:
+ @brief Creates an @c FIRAuthCredential for an email & password sign in.
+
+ @param email The user's email address.
+ @param password The user's password.
+ @return A FIRAuthCredential containing the email & password credential.
+ */
++ (FIRAuthCredential *)credentialWithEmail:(NSString *)email password:(NSString *)password;
+
+/** @fn init
+ @brief This class is not meant to be initialized.
+ */
+- (instancetype)init NS_UNAVAILABLE;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailAuthProvider.m b/Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailAuthProvider.m
new file mode 100644
index 0000000..d27611e
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailAuthProvider.m
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "FIREmailAuthProvider.h"
+
+#import "FIREmailPasswordAuthCredential.h"
+
+// FIREmailPasswordAuthProviderID is defined in FIRAuthProvider.m.
+
+@implementation FIREmailAuthProvider
+
+- (instancetype)init {
+ @throw [NSException exceptionWithName:@"Attempt to call unavailable initializer."
+ reason:@"This class is not meant to be initialized."
+ userInfo:nil];
+}
+
++ (FIRAuthCredential *)credentialWithEmail:(NSString *)email password:(NSString *)password {
+ return [[FIREmailPasswordAuthCredential alloc] initWithEmail:email password:password];
+}
+
+@end
diff --git a/Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailPasswordAuthCredential.h b/Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailPasswordAuthCredential.h
new file mode 100644
index 0000000..004716c
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailPasswordAuthCredential.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "../../Private/FIRAuthCredential_Internal.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/** @class FIREmailPasswordAuthCredential
+ @brief Internal implementation of FIRAuthCredential for Email/Password credentials.
+ */
+@interface FIREmailPasswordAuthCredential : FIRAuthCredential
+
+/** @property email
+ @brief The user's email address.
+ */
+@property(nonatomic, readonly) NSString *email;
+
+/** @property password
+ @brief The user's password.
+ */
+@property(nonatomic, readonly) NSString *password;
+
+/** @fn initWithEmail:password:
+ @brief Designated initializer.
+ @param email The user's email address.
+ @param password The user's password.
+ */
+- (nullable instancetype)initWithEmail:(NSString *)email password:(NSString *)password
+ NS_DESIGNATED_INITIALIZER;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailPasswordAuthCredential.m b/Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailPasswordAuthCredential.m
new file mode 100644
index 0000000..4361366
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailPasswordAuthCredential.m
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "FIREmailPasswordAuthCredential.h"
+
+#import "FIREmailAuthProvider.h"
+#import "FIRAuthExceptionUtils.h"
+#import "FIRVerifyAssertionRequest.h"
+
+@interface FIREmailPasswordAuthCredential ()
+
+- (nullable instancetype)initWithProvider:(NSString *)provider NS_UNAVAILABLE;
+
+@end
+
+@implementation FIREmailPasswordAuthCredential
+
+- (nullable instancetype)initWithProvider:(NSString *)provider {
+ [FIRAuthExceptionUtils raiseMethodNotImplementedExceptionWithReason:
+ @"Please call the designated initializer."];
+ return nil;
+}
+
+- (nullable instancetype)initWithEmail:(NSString *)email password:(NSString *)password {
+ self = [super initWithProvider:FIREmailAuthProviderID];
+ if (self) {
+ _email = [email copy];
+ _password = [password copy];
+ }
+ return self;
+}
+
+- (void)prepareVerifyAssertionRequest:(FIRVerifyAssertionRequest *)request {
+ [FIRAuthExceptionUtils raiseMethodNotImplementedExceptionWithReason:
+ @"Attempt to call prepareVerifyAssertionRequest: on a FIREmailPasswordAuthCredential."];
+}
+
+@end
diff --git a/Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailPasswordAuthProvider.h b/Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailPasswordAuthProvider.h
new file mode 100644
index 0000000..bf7db21
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailPasswordAuthProvider.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+
+@class FIRAuthCredential;
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ @brief A string constant identifying the email & password identity provider.
+ */
+extern NSString *const FIREmailPasswordAuthProviderID;
+
+/** @class FIREmailPasswordAuthProvider
+ @brief A concrete implementation of @c FIRAuthProvider for Email & Password Sign In.
+ */
+@interface FIREmailPasswordAuthProvider : NSObject
+
+/** @fn credentialWithEmail:password:
+ @brief Creates an @c FIRAuthCredential for an email & password sign in.
+
+ @param email The user's email address.
+ @param password The user's password.
+ @return A FIRAuthCredential containing the email & password credential.
+ */
++ (FIRAuthCredential *)credentialWithEmail:(NSString *)email password:(NSString *)password;
+
+/** @fn init
+ @brief This class is not meant to be initialized.
+ */
+- (instancetype)init NS_UNAVAILABLE;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailPasswordAuthProvider.m b/Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailPasswordAuthProvider.m
new file mode 100644
index 0000000..84c3787
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/EmailPassword/FIREmailPasswordAuthProvider.m
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "FIREmailPasswordAuthProvider.h"
+
+#import "FIREmailPasswordAuthCredential.h"
+
+// FIREmailPasswordAuthProviderID is defined in FIRAuthProvider.m.
+
+@implementation FIREmailPasswordAuthProvider
+
+- (instancetype)init {
+ @throw [NSException exceptionWithName:@"Attempt to call unavailable initializer."
+ reason:@"This class is not meant to be initialized."
+ userInfo:nil];
+}
+
++ (FIRAuthCredential *)credentialWithEmail:(NSString *)email password:(NSString *)password {
+ return [[FIREmailPasswordAuthCredential alloc] initWithEmail:email password:password];
+}
+
+@end
diff --git a/Firebase/Auth/Source/AuthProviders/Facebook/FIRFacebookAuthCredential.h b/Firebase/Auth/Source/AuthProviders/Facebook/FIRFacebookAuthCredential.h
new file mode 100644
index 0000000..1c03573
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/Facebook/FIRFacebookAuthCredential.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "../../Private/FIRAuthCredential_Internal.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/** @class FIRFacebookAuthCredential
+ @brief Internal implementation of FIRAuthCredential for the Facebook IdP.
+ */
+@interface FIRFacebookAuthCredential : FIRAuthCredential
+
+/** @fn initWithAccessToken:
+ @brief Designated initializer.
+ @param accessToken The Access Token obtained from Facebook.
+ */
+- (nullable instancetype)initWithAccessToken:(NSString *)accessToken NS_DESIGNATED_INITIALIZER;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firebase/Auth/Source/AuthProviders/Facebook/FIRFacebookAuthCredential.m b/Firebase/Auth/Source/AuthProviders/Facebook/FIRFacebookAuthCredential.m
new file mode 100644
index 0000000..1c3576a
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/Facebook/FIRFacebookAuthCredential.m
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "FIRFacebookAuthCredential.h"
+
+#import "FIRFacebookAuthProvider.h"
+#import "FIRAuthExceptionUtils.h"
+#import "FIRVerifyAssertionRequest.h"
+
+@interface FIRFacebookAuthCredential ()
+
+- (nullable instancetype)initWithProvider:(NSString *)provider NS_UNAVAILABLE;
+
+@end
+
+@implementation FIRFacebookAuthCredential {
+ NSString *_accessToken;
+}
+
+- (nullable instancetype)initWithProvider:(NSString *)provider {
+ [FIRAuthExceptionUtils raiseMethodNotImplementedExceptionWithReason:
+ @"Please call the designated initializer."];
+ return nil;
+}
+
+- (nullable instancetype)initWithAccessToken:(NSString *)accessToken {
+ self = [super initWithProvider:FIRFacebookAuthProviderID];
+ if (self) {
+ _accessToken = [accessToken copy];
+ }
+ return self;
+}
+
+- (void)prepareVerifyAssertionRequest:(FIRVerifyAssertionRequest *)request {
+ request.providerAccessToken = _accessToken;
+}
+
+@end
diff --git a/Firebase/Auth/Source/AuthProviders/Facebook/FIRFacebookAuthProvider.h b/Firebase/Auth/Source/AuthProviders/Facebook/FIRFacebookAuthProvider.h
new file mode 100644
index 0000000..2307b08
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/Facebook/FIRFacebookAuthProvider.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "FIRAuthSwiftNameSupport.h"
+
+@class FIRAuthCredential;
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ @brief A string constant identifying the Facebook identity provider.
+ */
+extern NSString *const FIRFacebookAuthProviderID FIR_SWIFT_NAME(FacebookAuthProviderID);
+
+/** @class FIRFacebookAuthProvider
+ @brief Utility class for constructing Facebook credentials.
+ */
+FIR_SWIFT_NAME(FacebookAuthProvider)
+@interface FIRFacebookAuthProvider : NSObject
+
+/** @fn credentialWithAccessToken:
+ @brief Creates an @c FIRAuthCredential for a Facebook sign in.
+
+ @param accessToken The Access Token from Facebook.
+ @return A FIRAuthCredential containing the Facebook credentials.
+ */
++ (FIRAuthCredential *)credentialWithAccessToken:(NSString *)accessToken;
+
+/** @fn init
+ @brief This class should not be initialized.
+ */
+- (instancetype)init NS_UNAVAILABLE;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firebase/Auth/Source/AuthProviders/Facebook/FIRFacebookAuthProvider.m b/Firebase/Auth/Source/AuthProviders/Facebook/FIRFacebookAuthProvider.m
new file mode 100644
index 0000000..d2759ae
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/Facebook/FIRFacebookAuthProvider.m
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "FIRFacebookAuthProvider.h"
+
+#import "FIRFacebookAuthCredential.h"
+#import "FIRAuthExceptionUtils.h"
+
+// FIRFacebookAuthProviderID is defined in FIRAuthProvider.m.
+
+@implementation FIRFacebookAuthProvider
+
+- (instancetype)init {
+ [FIRAuthExceptionUtils raiseMethodNotImplementedExceptionWithReason:
+ @"This class is not meant to be initialized."];
+ return nil;
+}
+
++ (FIRAuthCredential *)credentialWithAccessToken:(NSString *)accessToken {
+ return [[FIRFacebookAuthCredential alloc] initWithAccessToken:accessToken];
+}
+
+@end
diff --git a/Firebase/Auth/Source/AuthProviders/GitHub/FIRGitHubAuthCredential.h b/Firebase/Auth/Source/AuthProviders/GitHub/FIRGitHubAuthCredential.h
new file mode 100644
index 0000000..c43fb52
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/GitHub/FIRGitHubAuthCredential.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "../../Private/FIRAuthCredential_Internal.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/** @class FIRGitHubAuthCredential
+ @brief Internal implementation of FIRAuthCredential for GitHub credentials.
+ */
+@interface FIRGitHubAuthCredential : FIRAuthCredential
+
+/** @property token
+ @brief The GitHub OAuth access token.
+ */
+@property(nonatomic, readonly) NSString *token;
+
+/** @fn initWithToken:
+ @brief Designated initializer.
+ @param token The GitHub OAuth access token.
+ */
+- (nullable instancetype)initWithToken:(NSString *)token NS_DESIGNATED_INITIALIZER;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firebase/Auth/Source/AuthProviders/GitHub/FIRGitHubAuthCredential.m b/Firebase/Auth/Source/AuthProviders/GitHub/FIRGitHubAuthCredential.m
new file mode 100644
index 0000000..a0185eb
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/GitHub/FIRGitHubAuthCredential.m
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "FIRGitHubAuthCredential.h"
+
+#import "FIRGitHubAuthProvider.h"
+#import "FIRAuthExceptionUtils.h"
+#import "FIRVerifyAssertionRequest.h"
+
+@interface FIRGitHubAuthCredential ()
+
+- (nullable instancetype)initWithProvider:(NSString *)provider NS_UNAVAILABLE;
+
+@end
+
+@implementation FIRGitHubAuthCredential
+
+- (nullable instancetype)initWithProvider:(NSString *)provider {
+ [FIRAuthExceptionUtils raiseMethodNotImplementedExceptionWithReason:
+ @"Please call the designated initializer."];
+ return nil;
+}
+
+- (nullable instancetype)initWithToken:(NSString *)token {
+ self = [super initWithProvider:FIRGitHubAuthProviderID];
+ if (self) {
+ _token = [token copy];
+ }
+ return self;
+}
+
+- (void)prepareVerifyAssertionRequest:(FIRVerifyAssertionRequest *)request {
+ request.providerAccessToken = _token;
+}
+
+@end
diff --git a/Firebase/Auth/Source/AuthProviders/GitHub/FIRGitHubAuthProvider.h b/Firebase/Auth/Source/AuthProviders/GitHub/FIRGitHubAuthProvider.h
new file mode 100644
index 0000000..ab5c0ef
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/GitHub/FIRGitHubAuthProvider.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "FIRAuthSwiftNameSupport.h"
+
+@class FIRAuthCredential;
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ @brief A string constant identifying the GitHub identity provider.
+ */
+extern NSString *const FIRGitHubAuthProviderID FIR_SWIFT_NAME(GitHubAuthProviderID);
+
+/** @class FIRGitHubAuthProvider
+ @brief Utility class for constructing GitHub credentials.
+ */
+FIR_SWIFT_NAME(GitHubAuthProvider)
+@interface FIRGitHubAuthProvider : NSObject
+
+/** @fn credentialWithToken:
+ @brief Creates an @c FIRAuthCredential for a GitHub sign in.
+
+ @param token The GitHub OAuth access token.
+ @return A FIRAuthCredential containing the GitHub credential.
+ */
++ (FIRAuthCredential *)credentialWithToken:(NSString *)token;
+
+/** @fn init
+ @brief This class is not meant to be initialized.
+ */
+- (instancetype)init NS_UNAVAILABLE;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firebase/Auth/Source/AuthProviders/GitHub/FIRGitHubAuthProvider.m b/Firebase/Auth/Source/AuthProviders/GitHub/FIRGitHubAuthProvider.m
new file mode 100644
index 0000000..8e0ff76
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/GitHub/FIRGitHubAuthProvider.m
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "FIRGitHubAuthProvider.h"
+
+#import "FIRGitHubAuthCredential.h"
+#import "FIRAuthExceptionUtils.h"
+
+// FIRGitHubAuthProviderID is defined in FIRAuthProvider.m.
+
+@implementation FIRGitHubAuthProvider
+
+- (instancetype)init {
+ [FIRAuthExceptionUtils raiseMethodNotImplementedExceptionWithReason:
+ @"This class is not meant to be initialized."];
+ return nil;
+}
+
++ (FIRAuthCredential *)credentialWithToken:(NSString *)token {
+ return [[FIRGitHubAuthCredential alloc] initWithToken:token];
+}
+
+@end
diff --git a/Firebase/Auth/Source/AuthProviders/Google/FIRGoogleAuthCredential.h b/Firebase/Auth/Source/AuthProviders/Google/FIRGoogleAuthCredential.h
new file mode 100644
index 0000000..ae98fbc
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/Google/FIRGoogleAuthCredential.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "../../Private/FIRAuthCredential_Internal.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/** @class FIRGoogleAuthCredential
+ @brief Internal implementation of FIRAuthCredential for the Google IdP.
+ */
+@interface FIRGoogleAuthCredential : FIRAuthCredential
+
+/** @fn initWithIDToken:accessToken:
+ @brief Designated initializer.
+ @param IDToken The ID Token obtained from Google.
+ @param accessToken The Access Token obtained from Google.
+ */
+- (nullable instancetype)initWithIDToken:(NSString *)IDToken accessToken:(NSString *)accessToken
+ NS_DESIGNATED_INITIALIZER;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firebase/Auth/Source/AuthProviders/Google/FIRGoogleAuthCredential.m b/Firebase/Auth/Source/AuthProviders/Google/FIRGoogleAuthCredential.m
new file mode 100644
index 0000000..d66b2e2
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/Google/FIRGoogleAuthCredential.m
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "FIRGoogleAuthCredential.h"
+
+#import "FIRGoogleAuthProvider.h"
+#import "FIRAuthExceptionUtils.h"
+#import "FIRVerifyAssertionRequest.h"
+
+@interface FIRGoogleAuthCredential ()
+
+- (nullable instancetype)initWithProvider:(NSString *)provider NS_UNAVAILABLE;
+
+@end
+
+@implementation FIRGoogleAuthCredential {
+ NSString *_IDToken;
+ NSString *_accessToken;
+}
+
+- (nullable instancetype)initWithProvider:(NSString *)provider {
+ [FIRAuthExceptionUtils raiseMethodNotImplementedExceptionWithReason:
+ @"Please call the designated initializer."];
+ return nil;
+}
+
+- (nullable instancetype)initWithIDToken:(NSString *)IDToken accessToken:(NSString *)accessToken {
+ self = [super initWithProvider:FIRGoogleAuthProviderID];
+ if (self) {
+ _IDToken = [IDToken copy];
+ _accessToken = [accessToken copy];
+ }
+ return self;
+}
+
+- (void)prepareVerifyAssertionRequest:(FIRVerifyAssertionRequest *)request {
+ request.providerIDToken = _IDToken;
+ request.providerAccessToken = _accessToken;
+}
+
+@end
diff --git a/Firebase/Auth/Source/AuthProviders/Google/FIRGoogleAuthProvider.h b/Firebase/Auth/Source/AuthProviders/Google/FIRGoogleAuthProvider.h
new file mode 100644
index 0000000..92f0db2
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/Google/FIRGoogleAuthProvider.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "FIRAuthSwiftNameSupport.h"
+
+@class FIRAuthCredential;
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ @brief A string constant identifying the Google identity provider.
+ */
+extern NSString *const FIRGoogleAuthProviderID FIR_SWIFT_NAME(GoogleAuthProviderID);
+
+/** @class FIRGoogleAuthProvider
+ @brief Utility class for constructing Google Sign In credentials.
+ */
+FIR_SWIFT_NAME(GoogleAuthProvider)
+@interface FIRGoogleAuthProvider : NSObject
+
+/** @fn credentialWithIDToken:accessToken:
+ @brief Creates an @c FIRAuthCredential for a Google sign in.
+
+ @param IDToken The ID Token from Google.
+ @param accessToken The Access Token from Google.
+ @return A FIRAuthCredential containing the Google credentials.
+ */
++ (FIRAuthCredential *)credentialWithIDToken:(NSString *)IDToken
+ accessToken:(NSString *)accessToken;
+
+/** @fn init
+ @brief This class should not be initialized.
+ */
+- (instancetype)init NS_UNAVAILABLE;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firebase/Auth/Source/AuthProviders/Google/FIRGoogleAuthProvider.m b/Firebase/Auth/Source/AuthProviders/Google/FIRGoogleAuthProvider.m
new file mode 100644
index 0000000..a2f4c79
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/Google/FIRGoogleAuthProvider.m
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "FIRGoogleAuthProvider.h"
+
+#import "FIRGoogleAuthCredential.h"
+#import "FIRAuthExceptionUtils.h"
+
+// FIRGoogleAuthProviderID is defined in FIRAuthProvider.m.
+
+@implementation FIRGoogleAuthProvider
+
+- (instancetype)init {
+ [FIRAuthExceptionUtils raiseMethodNotImplementedExceptionWithReason:
+ @"This class is not meant to be initialized."];
+ return nil;
+}
+
++ (FIRAuthCredential *)credentialWithIDToken:(NSString *)IDToken
+ accessToken:(NSString *)accessToken {
+ return [[FIRGoogleAuthCredential alloc] initWithIDToken:IDToken accessToken:accessToken];
+}
+
+@end
diff --git a/Firebase/Auth/Source/AuthProviders/OAuth/FIROAuthCredential.h b/Firebase/Auth/Source/AuthProviders/OAuth/FIROAuthCredential.h
new file mode 100644
index 0000000..744df33
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/OAuth/FIROAuthCredential.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "../../Private/FIRAuthCredential_Internal.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/** @class FIROAuthCredential
+ @brief Internal implementation of FIRAuthCredential for generic credentials.
+ */
+@interface FIROAuthCredential : FIRAuthCredential
+
+/** @property providerID
+ @brief The provider ID associated with this credential.
+ */
+@property(nonatomic, readonly) NSString *providerID;
+
+/** @property IDToken
+ @brief The ID Token associated with this credential.
+ */
+@property(nonatomic, readonly) NSString *IDToken;
+
+/** @property accessToken
+ @brief The access token associated with this credential.
+ */
+@property(nonatomic, readonly) NSString *accessToken;
+
+/** @fn initWithProviderId:IDToken:accessToken:
+ @brief Designated initializer.
+ @param providerID The provider ID associated with the credential being created.
+ @param IDToken The ID Token associated with the credential being created.
+ @param accessToken The access token associated with the credential being created.
+ */
+- (nullable instancetype)initWithProvierID:(NSString *)providerID
+ IDToken:(nullable NSString*)IDToken
+ accessToken:(nullable NSString *)accessToken;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firebase/Auth/Source/AuthProviders/OAuth/FIROAuthCredential.m b/Firebase/Auth/Source/AuthProviders/OAuth/FIROAuthCredential.m
new file mode 100644
index 0000000..28712a6
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/OAuth/FIROAuthCredential.m
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "FIROAuthCredential.h"
+#import "FIRAuthExceptionUtils.h"
+#import "FIRVerifyAssertionRequest.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface FIROAuthCredential ()
+
+- (nullable instancetype)initWithProvider:(NSString *)provider NS_UNAVAILABLE;
+
+@end
+
+@implementation FIROAuthCredential
+
+- (nullable instancetype)initWithProvierID:(NSString *)providerID
+ IDToken:(nullable NSString *)IDToken
+ accessToken:(nullable NSString *)accessToken {
+ self = [super initWithProvider:providerID];
+ if (self) {
+ _providerID = providerID;
+ _IDToken = IDToken;
+ _accessToken = accessToken;
+ }
+ return self;
+}
+
+- (void)prepareVerifyAssertionRequest:(FIRVerifyAssertionRequest *)request {
+ request.providerIDToken = _IDToken;
+ request.providerAccessToken = _accessToken;
+}
+
+NS_ASSUME_NONNULL_END
+
+@end
diff --git a/Firebase/Auth/Source/AuthProviders/OAuth/FIROAuthProvider.h b/Firebase/Auth/Source/AuthProviders/OAuth/FIROAuthProvider.h
new file mode 100644
index 0000000..e059b22
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/OAuth/FIROAuthProvider.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "FIRAuthSwiftNameSupport.h"
+
+@class FIRAuthCredential;
+
+NS_ASSUME_NONNULL_BEGIN
+
+/** @class FIROAuthProvider
+ @brief A concrete implementation of @c FIRAuthProvider for generic OAuth Providers.
+ */
+FIR_SWIFT_NAME(OAuthProvider)
+@interface FIROAuthProvider : NSObject
+
+/** @fn credentialWithProviderID:IDToken:accessToken:
+ @brief Creates an @c FIRAuthCredential for that OAuth 2 provider identified by providerID, ID
+ token and access token.
+
+ @param providerID The provider ID associated with the Auth credential being created.
+ @param IDToken The IDToken associated with the Auth credential being created.
+ @param accessToken The accessstoken associated with the Auth credential be created, if
+ available.
+ @return A FIRAuthCredential for the specified provider ID, ID token and access token.
+ */
++ (FIRAuthCredential *)credentialWithProviderID:(NSString *)providerID
+ IDToken:(NSString *)IDToken
+ accessToken:(nullable NSString *)accessToken;
+
+
+/** @fn credentialWithProviderID:accessToken:
+ @brief Creates an @c FIRAuthCredential for that OAuth 2 provider identified by providerID using
+ an ID token.
+
+ @param providerID The provider ID associated with the Auth credential being created.
+ @param accessToken The accessstoken associated with the Auth credential be created
+ @return A FIRAuthCredential.
+ */
++ (FIRAuthCredential *)credentialWithProviderID:(NSString *)providerID
+ accessToken:(NSString *)accessToken;
+
+/** @fn init
+ @brief This class is not meant to be initialized.
+ */
+- (instancetype)init NS_UNAVAILABLE;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firebase/Auth/Source/AuthProviders/OAuth/FIROAuthProvider.m b/Firebase/Auth/Source/AuthProviders/OAuth/FIROAuthProvider.m
new file mode 100644
index 0000000..e810680
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/OAuth/FIROAuthProvider.m
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "FIROAuthProvider.h"
+
+#import "FIROAuthCredential.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@implementation FIROAuthProvider
+
++ (FIRAuthCredential *)credentialWithProviderID:(NSString *)providerID
+ IDToken:(NSString *)IDToken
+ accessToken:(nullable NSString *)accessToken {
+ return [[FIROAuthCredential alloc] initWithProvierID:providerID
+ IDToken:IDToken
+ accessToken:accessToken];
+}
+
++ (FIROAuthCredential *)credentialWithProviderID:(NSString *)providerID
+ accessToken:(NSString *)accessToken {
+ return [[FIROAuthCredential alloc] initWithProvierID:providerID
+ IDToken:nil
+ accessToken:accessToken];
+}
+
+NS_ASSUME_NONNULL_END
+
+@end
diff --git a/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthCredential.h b/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthCredential.h
new file mode 100644
index 0000000..d951564
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthCredential.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "FIRAuthCredential.h"
+#import "FIRAuthSwiftNameSupport.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/** @class FIRPhoneAuthCredential
+ @brief Implementation of FIRAuthCredential for Phone Auth credentials.
+ */
+FIR_SWIFT_NAME(PhoneAuthCredential)
+@interface FIRPhoneAuthCredential : FIRAuthCredential
+
+/** @fn init
+ @brief This class is not supposed to be instantiated directly.
+ */
+- (instancetype)init NS_UNAVAILABLE;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthCredential.m b/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthCredential.m
new file mode 100644
index 0000000..b9bf577
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthCredential.m
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "FIRPhoneAuthCredential.h"
+
+#import "FIRPhoneAuthProvider.h"
+#import "FIRPhoneAuthCredential_Internal.h"
+#import "FIRAuthCredential_Internal.h"
+#import "FIRAuthExceptionUtils.h"
+#import "FIRVerifyAssertionRequest.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface FIRPhoneAuthCredential ()
+
+- (nullable instancetype)initWithProvider:(NSString *)provider NS_UNAVAILABLE;
+
+@end
+
+@implementation FIRPhoneAuthCredential
+
+- (instancetype)initWithTemporaryProof:(NSString *)temporaryProof
+ phoneNumber:(NSString *)phoneNumber
+ providerID:(NSString *)providerID {
+ self = [super initWithProvider:providerID];
+ if (self) {
+ _temporaryProof = [temporaryProof copy];
+ _phoneNumber = [phoneNumber copy];
+ }
+ return self;
+}
+
+- (nullable instancetype)initWithProvider:(NSString *)provider {
+ [FIRAuthExceptionUtils raiseMethodNotImplementedExceptionWithReason:
+ @"Please call the designated initializer."];
+ return nil;
+}
+
+- (instancetype)initWithProviderID:(NSString *)providerID
+ verificationID:(NSString *)verificationID
+ verificationCode:(NSString *)verificationCode {
+ self = [super initWithProvider:providerID];
+ if (self) {
+ _verificationID = [verificationID copy];
+ _verificationCode = [verificationCode copy];
+ }
+ return self;
+}
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthCredential_Internal.h b/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthCredential_Internal.h
new file mode 100644
index 0000000..f260b89
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthCredential_Internal.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#import <Foundation/Foundation.h>
+
+#import "FIRPhoneAuthCredential.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/** @extension FIRPhoneAuthCredential
+ @brief Internal implementation of FIRAuthCredential for Phone Auth credentials.
+ */
+@interface FIRPhoneAuthCredential ()
+
+/** @var verificationID
+ @brief The verification ID obtained from invoking @c verifyPhoneNumber:completion:
+ */
+@property(nonatomic, readonly, nonnull) NSString *verificationID;
+
+/** @var verificationCode
+ @brief The verification code provided by the user.
+ */
+@property(nonatomic, readonly, nonnull) NSString *verificationCode;
+
+/** @var temporaryProof
+ @brief The a temporary proof code perftaining to this credential, returned from the backend.
+ */
+@property(nonatomic, readonly, nonnull) NSString *temporaryProof;
+
+/** @var phoneNumber
+ @brief The a phone number pertaining to this credential, returned from the backend.
+ */
+@property(nonatomic, readonly, nonnull) NSString *phoneNumber;
+
+/** @var initWithTemporaryProof:phoneNumber:
+ @brief Designated Initializer.
+ @param providerID The provider ID associated with the phone auth credential being created.
+ */
+- (instancetype)initWithTemporaryProof:(NSString *)temporaryProof
+ phoneNumber:(NSString *)phoneNumber
+ providerID:(NSString *)providerID NS_DESIGNATED_INITIALIZER;
+
+/** @var initWithProviderID:verificationID:verificationCode:
+ @brief Designated Initializer.
+ @param providerID The provider ID associated with the phone auth credential being created.
+ @param verificationID The verification ID associated witht Phone Auth credential being created.
+ @param verificationCode The verification code associated witht Phone Auth credential being
+ created.
+ */
+- (instancetype)initWithProviderID:(NSString *)providerID
+ verificationID:(NSString *)verificationID
+ verificationCode:(NSString *)verificationCode NS_DESIGNATED_INITIALIZER;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthProvider.h b/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthProvider.h
new file mode 100644
index 0000000..bc12b43
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthProvider.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "FIRAuth.h"
+#import "FIRAuthSwiftNameSupport.h"
+
+@class FIRPhoneAuthCredential;
+
+NS_ASSUME_NONNULL_BEGIN
+
+/** @var FIRPhoneAuthProviderID
+ @brief A string constant identifying the phone identity provider.
+ */
+extern NSString *const FIRPhoneAuthProviderID FIR_SWIFT_NAME(PhoneAuthProviderID);
+
+/** @typedef FIRVerificationResultCallback
+ @brief The type of block invoked when a request to send a verification code has finished.
+
+ @param verificationID On success, the verification ID provided, nil otherwise.
+ @param error On error, the error that occured, nil otherwise.
+ */
+typedef void (^FIRVerificationResultCallback)(NSString *_Nullable verificationID,
+ NSError *_Nullable error)
+ FIR_SWIFT_NAME(VerificationResultCallback);
+
+/** @class FIRPhoneNumberProvider
+ @brief A concrete implementation of @c FIRAuthProvider for Phone Auth Providers.
+ */
+FIR_SWIFT_NAME(PhoneAuthProvider)
+@interface FIRPhoneAuthProvider : NSObject
+
+/** @fn provider
+ @brief Returns an instance of @c FIRPhoneAuthProvider for the default @c FIRAuth object.
+ */
++ (instancetype)provider FIR_SWIFT_NAME(provider());
+
+/** @fn providerWithAuth:
+ @brief Returns an instance of @c FIRPhoneAuthProvider for the provided @c FIRAuth object.
+
+ @param auth The auth object to associate with the @c PhoneauthProvider instance.
+ */
++ (instancetype)providerWithAuth:(FIRAuth *)auth FIR_SWIFT_NAME(provider(auth:));
+
+/** @fn verifyPhoneNumber:completion:
+ @brief Starts the phone number authentication flow by sending a verifcation code to the
+ specified phone number.
+
+ @param phoneNumber The phone number to be verified.
+ @param completion The callback to be invoked when the verification flow is finished.
+ */
+- (void)verifyPhoneNumber:(NSString *)phoneNumber
+ completion:(nullable FIRVerificationResultCallback)completion;
+
+/** @fn credentialWithVerificationID:verificationCode:
+ @brief Creates an @c FIRAuthCredential for the phone number provider identified by the
+ verification ID and verification code.
+
+ @param verificationID The verification ID obtained from invoking @c
+ verifyPhoneNumber:completion:
+ @param verificationCode The verification code obtained from the user.
+ @return The corresponding @c FIRAuthCredential for the verification ID and verification code
+ provided.
+ */
+- (FIRPhoneAuthCredential *)credentialWithVerificationID:(NSString *)verificationID
+ verificationCode:(NSString *)verificationCode;
+
+/** @fn init
+ @brief Please use the @c provider or @providerWithAuth: methods to obtain an instance of @c
+ FIRPhoneAuthProvider.
+ */
+- (instancetype)init NS_UNAVAILABLE;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthProvider.m b/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthProvider.m
new file mode 100644
index 0000000..423b2b6
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthProvider.m
@@ -0,0 +1,213 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "FIRPhoneAuthProvider.h"
+
+#import "FIRLogger.h"
+#import "FIRPhoneAuthCredential_Internal.h"
+#import "NSString+FIRAuth.h"
+#import "../../Private/FIRAuthAPNSToken.h"
+#import "../../Private/FIRAuthAPNSTokenManager.h"
+#import "../../Private/FIRAuthAppCredential.h"
+#import "../../Private/FIRAuthAppCredentialManager.h"
+#import "../../Private/FIRAuthGlobalWorkQueue.h"
+#import "../../Private/FIRAuth_Internal.h"
+#import "../../Private/FIRAuthNotificationManager.h"
+#import "../../Private/FIRAuthErrorUtils.h"
+#import "FIRAuthBackend.h"
+#import "FIRSendVerificationCodeRequest.h"
+#import "FIRSendVerificationCodeResponse.h"
+#import "FIRVerifyClientRequest.h"
+#import "FIRVerifyClientResponse.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/** @typedef FIRVerifyClientCallback
+ @brief The callback invoked at the end of a client verification flow.
+ @param appCredential credential that proves the identity of the app during a phone
+ authentication flow.
+ @param error The error that occured while verifying the app, if any.
+ */
+typedef void (^FIRVerifyClientCallback)(FIRAuthAppCredential *_Nullable appCredential,
+ NSError *_Nullable error);
+
+@implementation FIRPhoneAuthProvider {
+
+ /** @var _auth
+ @brief The auth instance used to for verifying the phone number.
+ */
+ FIRAuth *_auth;
+}
+
+/** @fn initWithAuth:
+ @brief returns an instance of @c FIRPhoneAuthProvider assocaited with the provided auth
+ instance.
+ @return An Instance of @c FIRPhoneAuthProvider.
+ */
+- (nullable instancetype)initWithAuth:(FIRAuth *)auth {
+ self = [super init];
+ if (self) {
+ _auth = auth;
+ }
+ return self;
+}
+
+- (void)verifyPhoneNumber:(NSString *)phoneNumber
+ completion:(nullable FIRVerificationResultCallback)completion {
+ dispatch_async(FIRAuthGlobalWorkQueue(), ^{
+ FIRVerificationResultCallback callBackOnMainThread = ^(NSString *_Nullable verificationID,
+ NSError *_Nullable error) {
+ if (completion) {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ completion(verificationID, error);
+ });
+ }
+ };
+
+ if (!phoneNumber.length) {
+ callBackOnMainThread(nil,
+ [FIRAuthErrorUtils missingPhoneNumberErrorWithMessage:nil]);
+ return;
+ }
+ [_auth.notificationManager checkNotificationForwardingWithCallback:
+ ^(BOOL isNotificationBeingForwarded) {
+ if (!isNotificationBeingForwarded) {
+ callBackOnMainThread(nil, [FIRAuthErrorUtils notificationNotForwardedError]);
+ return;
+ }
+ [self verifyClientAndSendVerificationCodeToPhoneNumber:phoneNumber
+ retryOnInvalidAppCredential:YES
+ callback:callBackOnMainThread];
+ }];
+ });
+}
+
+- (FIRPhoneAuthCredential *)credentialWithVerificationID:(NSString *)verificationID
+ verificationCode:(NSString *)verificationCode {
+ return [[FIRPhoneAuthCredential alloc] initWithProviderID:FIRPhoneAuthProviderID
+ verificationID:verificationID
+ verificationCode:verificationCode];
+}
+
++ (instancetype)provider {
+ return [[self alloc]initWithAuth:[FIRAuth auth]];
+}
+
++ (instancetype)providerWithAuth:(FIRAuth *)auth {
+ return [[self alloc]initWithAuth:auth];
+}
+
+#pragma mark - Internal Methods
+
+/** @fn verifyClientAndSendVerificationCodeToPhoneNumber:retryOnInvalidAppCredential:callback:
+ @brief Starts the flow to verify the client via silent push notification.
+ @param retryOnInvalidAppCredential Whether of not the flow should be retried if an
+ FIRAuthErrorCodeInvalidAppCredential error is returned from the backend.
+ @param phoneNumber The phone number to be verified.
+ @param callback The callback to be invoked on the global work queue when the flow is
+ finished.
+ */
+- (void)verifyClientAndSendVerificationCodeToPhoneNumber:(NSString *)phoneNumber
+ retryOnInvalidAppCredential:(BOOL)retryOnInvalidAppCredential
+ callback:(FIRVerificationResultCallback)callback {
+ [self verifyClientWithCompletion:^(FIRAuthAppCredential *_Nullable appCredential,
+ NSError *_Nullable error) {
+ if (error) {
+ callback(nil, error);
+ return;
+ }
+ FIRSendVerificationCodeRequest *request =
+ [[FIRSendVerificationCodeRequest alloc] initWithPhoneNumber:phoneNumber
+ appCredential:appCredential
+ APIKey:_auth.APIKey];
+ [FIRAuthBackend sendVerificationCode:request
+ callback:^(FIRSendVerificationCodeResponse *_Nullable response,
+ NSError *_Nullable error) {
+ if (error) {
+ if (error.code == FIRAuthErrorCodeInvalidAppCredential) {
+ if (retryOnInvalidAppCredential) {
+ [_auth.appCredentialManager clearCredential];
+ [self verifyClientAndSendVerificationCodeToPhoneNumber:phoneNumber
+ retryOnInvalidAppCredential:NO
+ callback:callback];
+ return;
+ }
+ callback(nil, [FIRAuthErrorUtils unexpectedResponseWithDeserializedResponse:nil
+ underlyingError:error]);
+ return;
+ }
+ callback(nil, error);
+ return;
+ }
+ // Associate the phone number with the verification ID.
+ response.verificationID.fir_authPhoneNumber = phoneNumber;
+ callback(response.verificationID, nil);
+ }];
+ }];
+}
+
+/** @fn verifyClientWithCompletion:completion:
+ @brief Continues the flow to verify the client via silent push notification.
+ @param completion The callback to be invoked when the client verification flow is finished.
+ */
+- (void)verifyClientWithCompletion:(FIRVerifyClientCallback)completion {
+ if (_auth.appCredentialManager.credential) {
+ completion(_auth.appCredentialManager.credential, nil);
+ return;
+ }
+ [_auth.tokenManager getTokenWithCallback:^(FIRAuthAPNSToken * _Nullable token) {
+ if (!token) {
+ completion(nil, [FIRAuthErrorUtils missingAppTokenError]);
+ return;
+ }
+
+ // Convert token data to hex string.
+ NSUInteger capacity = token.data.length * 2;
+ NSMutableString *tokenString = [NSMutableString stringWithCapacity:capacity];
+ const unsigned char *tokenData = token.data.bytes;
+ for (int idx = 0; idx < token.data.length; ++idx) {
+ [tokenString appendFormat:@"%02X", (int)tokenData[idx]];
+ }
+
+ FIRVerifyClientRequest *request =
+ [[FIRVerifyClientRequest alloc] initWithAppToken:tokenString
+ isSandbox:token.type == FIRAuthAPNSTokenTypeSandbox
+ APIKey:_auth.APIKey];
+ [FIRAuthBackend verifyClient:request callback:^(FIRVerifyClientResponse *_Nullable response,
+ NSError *_Nullable error) {
+ if (error) {
+ completion(nil, error);
+ return;
+ }
+ NSTimeInterval timeout = [response.suggestedTimeOutDate timeIntervalSinceNow];
+ [_auth.appCredentialManager
+ didStartVerificationWithReceipt:response.receipt
+ timeout:timeout
+ callback:^(FIRAuthAppCredential *credential) {
+ if (!credential.secret) {
+ FIRLogError(kFIRLoggerAuth, @"I-AUT000014",
+ @"Failed to receive remote notification to verify app identity within "
+ @"%.0f second(s)", timeout);
+ }
+ completion(credential, nil);
+ }];
+ }];
+ }];
+}
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firebase/Auth/Source/AuthProviders/Phone/NSString+FIRAuth.h b/Firebase/Auth/Source/AuthProviders/Phone/NSString+FIRAuth.h
new file mode 100644
index 0000000..ba123fa
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/Phone/NSString+FIRAuth.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+/** @category NSString(FIRAuth)
+ @brief A FIRAuth category for extending the functionality of NSString for specific Firebase Auth
+ use cases.
+ */
+@interface NSString (FIRAuth)
+
+/** @property fir_authPhoneNumber
+ @brief A phone number associated with the verification ID (NSString instance).
+ @remarks Allows an instance on NSString to be associated with a phone number in order to link
+ phone number with the verificationID returned from verifyPhoneNumber:completion:
+ */
+@property(nonatomic, strong) NSString *fir_authPhoneNumber;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firebase/Auth/Source/AuthProviders/Phone/NSString+FIRAuth.m b/Firebase/Auth/Source/AuthProviders/Phone/NSString+FIRAuth.m
new file mode 100644
index 0000000..87f3b1c
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/Phone/NSString+FIRAuth.m
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "NSString+FIRAuth.h"
+
+#import <objc/runtime.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@implementation NSString (FIRAuth)
+
+- (void)setFir_authPhoneNumber:(NSString *)phoneNumber {
+ objc_setAssociatedObject(self, @selector(fir_authPhoneNumber), phoneNumber,
+ OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+}
+
+- (NSString *)fir_authPhoneNumber {
+ return objc_getAssociatedObject(self, @selector(fir_authPhoneNumber));
+}
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firebase/Auth/Source/AuthProviders/Twitter/FIRTwitterAuthCredential.h b/Firebase/Auth/Source/AuthProviders/Twitter/FIRTwitterAuthCredential.h
new file mode 100644
index 0000000..5fab4e2
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/Twitter/FIRTwitterAuthCredential.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "../../Private/FIRAuthCredential_Internal.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/** @class FIRTwitterAuthCredential
+ @brief Internal implementation of FIRAuthCredential for Twitter credentials.
+ */
+@interface FIRTwitterAuthCredential : FIRAuthCredential
+
+/** @property token
+ @brief The Twitter OAuth token.
+ */
+@property(nonatomic, readonly) NSString *token;
+
+/** @property secret
+ @brief The Twitter OAuth secret.
+ */
+@property(nonatomic, readonly) NSString *secret;
+
+/** @fn initWithToken:secret:
+ @brief Designated initializer.
+ @param token The Twitter OAuth token.
+ @param secret The Twitter OAuth secret.
+ */
+- (nullable instancetype)initWithToken:(NSString *)token secret:(NSString *)secret
+ NS_DESIGNATED_INITIALIZER;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firebase/Auth/Source/AuthProviders/Twitter/FIRTwitterAuthCredential.m b/Firebase/Auth/Source/AuthProviders/Twitter/FIRTwitterAuthCredential.m
new file mode 100644
index 0000000..6772d6f
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/Twitter/FIRTwitterAuthCredential.m
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "FIRTwitterAuthCredential.h"
+
+#import "FIRTwitterAuthProvider.h"
+#import "FIRAuthExceptionUtils.h"
+#import "FIRVerifyAssertionRequest.h"
+
+@interface FIRTwitterAuthCredential ()
+
+- (nullable instancetype)initWithProvider:(NSString *)provider NS_UNAVAILABLE;
+
+@end
+
+@implementation FIRTwitterAuthCredential
+
+- (nullable instancetype)initWithProvider:(NSString *)provider {
+ [FIRAuthExceptionUtils raiseMethodNotImplementedExceptionWithReason:
+ @"Please call the designated initializer."];
+ return nil;
+}
+
+- (nullable instancetype)initWithToken:(NSString *)token secret:(NSString *)secret {
+ self = [super initWithProvider:FIRTwitterAuthProviderID];
+ if (self) {
+ _token = [token copy];
+ _secret = [secret copy];
+ }
+ return self;
+}
+
+- (void)prepareVerifyAssertionRequest:(FIRVerifyAssertionRequest *)request {
+ request.providerAccessToken = _token;
+ request.providerOAuthTokenSecret = _secret;
+}
+
+@end
diff --git a/Firebase/Auth/Source/AuthProviders/Twitter/FIRTwitterAuthProvider.h b/Firebase/Auth/Source/AuthProviders/Twitter/FIRTwitterAuthProvider.h
new file mode 100644
index 0000000..d8f647d
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/Twitter/FIRTwitterAuthProvider.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "FIRAuthSwiftNameSupport.h"
+
+@class FIRAuthCredential;
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ @brief A string constant identifying the Twitter identity provider.
+ */
+extern NSString *const FIRTwitterAuthProviderID FIR_SWIFT_NAME(TwitterAuthProviderID);
+
+/** @class FIRTwitterAuthProvider
+ @brief Utility class for constructing Twitter credentials.
+ */
+FIR_SWIFT_NAME(TwitterAuthProvider)
+@interface FIRTwitterAuthProvider : NSObject
+
+/** @fn credentialWithToken:secret:
+ @brief Creates an @c FIRAuthCredential for a Twitter sign in.
+
+ @param token The Twitter OAuth token.
+ @param secret The Twitter OAuth secret.
+ @return A FIRAuthCredential containing the Twitter credential.
+ */
++ (FIRAuthCredential *)credentialWithToken:(NSString *)token secret:(NSString *)secret;
+
+/** @fn init
+ @brief This class is not meant to be initialized.
+ */
+- (instancetype)init NS_UNAVAILABLE;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/Firebase/Auth/Source/AuthProviders/Twitter/FIRTwitterAuthProvider.m b/Firebase/Auth/Source/AuthProviders/Twitter/FIRTwitterAuthProvider.m
new file mode 100644
index 0000000..5d738ce
--- /dev/null
+++ b/Firebase/Auth/Source/AuthProviders/Twitter/FIRTwitterAuthProvider.m
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017 Google
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "FIRTwitterAuthProvider.h"
+
+#import "FIRTwitterAuthCredential.h"
+#import "FIRAuthExceptionUtils.h"
+
+// FIRTwitterAuthProviderID is defined in FIRAuthProvider.m.
+
+@implementation FIRTwitterAuthProvider
+
+- (instancetype)init {
+ [FIRAuthExceptionUtils raiseMethodNotImplementedExceptionWithReason:
+ @"This class is not meant to be initialized."];
+ return nil;
+}
+
++ (FIRAuthCredential *)credentialWithToken:(NSString *)token secret:(NSString *)secret {
+ return [[FIRTwitterAuthCredential alloc] initWithToken:token secret:secret];
+}
+
+@end