-
Notifications
You must be signed in to change notification settings - Fork 242
/
auth_apple_signin_nonce.js
30 lines (26 loc) · 954 Bytes
/
auth_apple_signin_nonce.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// This snippet file was generated by processing the source file:
// ./auth-next/apple.js
//
// To update the snippets in this file, edit the source and then run
// 'npm run snippets'.
// [START auth_apple_signin_nonce_modular]
import { getAuth, signInWithCredential, OAuthProvider } from "firebase/auth";
const auth = getAuth();
// Build Firebase credential with the Apple ID token.
const provider = new OAuthProvider('apple.com');
const authCredential = provider.credential({
idToken: appleIdToken,
rawNonce: unhashedNonce,
});
// Sign in with credential form the Apple user.
signInWithCredential(auth, authCredential)
.then((result) => {
// User signed in.
})
.catch((error) => {
// An error occurred. If error.code == 'auth/missing-or-invalid-nonce',
// make sure you're sending the SHA256-hashed nonce as a hex string
// with your request to Apple.
console.log(error);
});
// [END auth_apple_signin_nonce_modular]