Skip to content

Commit 3f6babd

Browse files
Googlera-maurice
authored andcommitted
Example Snippets used for Apple Sign In sample documentation.
PiperOrigin-RevId: 291009401
1 parent f624462 commit 3f6babd

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

auth/samples/src/doc_samples.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ struct MyProgramContext {
4444
JNIEnv* my_jni_env = nullptr;
4545
jobject my_activity = nullptr;
4646
#endif // defined(__ANDROID__)
47+
const char* apple_id_token = nullptr;
48+
const char* raw_nonce = nullptr;
4749
const char* email = nullptr;
4850
const char* password = nullptr;
4951
const char* google_id_token = nullptr;
@@ -74,6 +76,14 @@ firebase::auth::Auth* AuthFromApp(firebase::App* app) {
7476
}
7577

7678
void VariousCredentials(firebase::auth::Auth* auth) {
79+
{
80+
// [START auth_credential_apple]
81+
firebase::auth::Credential credential =
82+
firebase::auth::OAuthProvider::GetCredential(
83+
"apple.com", apple_id_token, raw_nonce, nullptr);
84+
// [END auth_credential_apple]
85+
(void)credential;
86+
}
7787
{
7888
// [START auth_credential_email]
7989
firebase::auth::Credential credential =
@@ -113,6 +123,16 @@ void VariousSignIns(firebase::auth::Auth* auth) {
113123
// [END auth_create_user]
114124
(void)result;
115125
}
126+
{
127+
// [START auth_sign_in_apple]
128+
firebase::auth::Credential credential =
129+
firebase::auth::OAuthProvider::GetCredential(
130+
"apple.com", apple_id_token, raw_nonce, nullptr);
131+
firebase::Future<firebase::auth::User*> result =
132+
auth->SignInWithCredential(credential);
133+
// [END auth_sign_in_apple]
134+
(void)result;
135+
}
116136
{
117137
// [START auth_sign_in_email]
118138
firebase::Future<firebase::auth::User*> result =

0 commit comments

Comments
 (0)