aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firebase/Auth/Source/AuthProviders/OAuth
diff options
context:
space:
mode:
Diffstat (limited to 'Firebase/Auth/Source/AuthProviders/OAuth')
-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
4 files changed, 211 insertions, 0 deletions
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