Skip to content

Commit 93aca4c

Browse files
committed
add generated snippets
1 parent 6699a53 commit 93aca4c

19 files changed

+340
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./auth-next/index.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_init_custom_domain_modular]
8+
import { initializeApp } from "firebase/app";
9+
10+
const firebaseConfig = {
11+
apiKey: "...",
12+
// By default, authDomain is '[YOUR_APP].firebaseapp.com'.
13+
// You may replace it with a custom domain.
14+
authDomain: '[YOUR_CUSTOM_DOMAIN]'
15+
};
16+
const firebaseApp = initializeApp(firebaseConfig);
17+
// [END auth_init_custom_domain_modular]
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./auth-next/oidc.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_oidc_direct_sign_in_modular]
8+
import { getAuth, OAuthProvider, signInWithCredential } from "firebase/auth";
9+
10+
const auth = getAuth();
11+
const credential = provider.credential({
12+
idToken: oidcIdToken,
13+
});
14+
signInWithCredential(auth, credential)
15+
.then((result) => {
16+
// User is signed in.
17+
const newCredential = OAuthProvider.credentialFromResult(result);
18+
// This gives you a new access token for the OIDC provider. You can use it to directly interact with that provider.
19+
})
20+
.catch((error) => {
21+
// Handle Errors here.
22+
const errorCode = error.code;
23+
const errorMessage = error.message;
24+
// The email of the user's account used.
25+
const email = error.email;
26+
// The AuthCredential type that was used.
27+
const credential = OAuthProvider.credentialFromError(error);
28+
// Handle / display error.
29+
// ...
30+
});
31+
// [END auth_oidc_direct_sign_in_modular]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./auth-next/oidc.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_oidc_provider_create_modular]
8+
import { OAuthProvider } from "firebase/auth";
9+
10+
const provider = new OAuthProvider("oidc.myProvider");
11+
// [END auth_oidc_provider_create_modular]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./auth-next/oidc.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_oidc_signin_popup_modular]
8+
import { getAuth, signInWithPopup, OAuthProvider } from "firebase/auth";
9+
10+
const auth = getAuth();
11+
signInWithPopup(auth, provider)
12+
.then((result) => {
13+
// User is signed in.
14+
const credential = OAuthProvider.credentialFromResult(result);
15+
// This gives you an access token for the OIDC provider. You can use it to directly interact with that provider
16+
}).catch((error) => {
17+
// Handle Errors here.
18+
const errorCode = error.code;
19+
const errorMessage = error.message;
20+
// The email of the user's account used.
21+
const email = error.email;
22+
// The AuthCredential type that was used.
23+
const credential = OAuthProvider.credentialFromError(error);
24+
// Handle / display error.
25+
// ...
26+
});
27+
// [END auth_oidc_signin_popup_modular]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./auth-next/oidc.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_oidc_signin_redirect_modular]
8+
import { getAuth, signInWithRedirect } from "firebase/auth";
9+
10+
const auth = getAuth();
11+
signInWithRedirect(auth, provider);
12+
// [END auth_oidc_signin_redirect_modular]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./auth-next/oidc.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_oidc_signin_redirect_result_modular]
8+
import { getAuth, getRedirectResult, OAuthProvider } from "firebase/auth";
9+
10+
const auth = getAuth();
11+
getRedirectResult(auth)
12+
.then((result) => {
13+
// User is signed in.
14+
const credential = OAuthProvider.credentialFromResult(result);
15+
// This gives you an access token for the OIDC provider. You can use it to directly interact with that provider
16+
})
17+
.catch((error) => {
18+
// Handle Errors here.
19+
const errorCode = error.code;
20+
const errorMessage = error.message;
21+
// The email of the user's account used.
22+
const email = error.email;
23+
// The AuthCredential type that was used.
24+
const credential = OAuthProvider.credentialFromError(error);
25+
// Handle / display error.
26+
// ...
27+
});
28+
// [END auth_oidc_signin_redirect_result_modular]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./auth-next/saml.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_saml_provider_create_modular]
8+
import { SAMLAuthProvider } from "firebase/auth";
9+
10+
const provider = new SAMLAuthProvider("saml.myProvider");
11+
// [END auth_saml_provider_create_modular]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./auth-next/saml.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_saml_signin_popup_modular]
8+
import { getAuth, signInWithPopup, SAMLAuthProvider } from "firebase/auth";
9+
10+
const auth = getAuth();
11+
signInWithPopup(auth, provider)
12+
.then((result) => {
13+
// User is signed in.
14+
// Provider data available from the result.user.getIdToken()
15+
// or from result.user.providerData
16+
}).catch((error) => {
17+
// Handle Errors here.
18+
const errorCode = error.code;
19+
const errorMessage = error.message;
20+
// The email of the user's account used.
21+
const email = error.email;
22+
// The AuthCredential type that was used.
23+
const credential = SAMLAuthProvider.credentialFromError(error);
24+
// Handle / display error.
25+
// ...
26+
});
27+
// [END auth_saml_signin_popup_modular]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./auth-next/saml.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_saml_signin_redirect_modular]
8+
import { getAuth, signInWithRedirect } from "firebase/auth";
9+
10+
const auth = getAuth();
11+
signInWithRedirect(auth, provider);
12+
// [END auth_saml_signin_redirect_modular]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./auth-next/saml.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_saml_signin_redirect_result_modular]
8+
import { getAuth, getRedirectResult, SAMLAuthProvider } from "firebase/auth";
9+
10+
const auth = getAuth();
11+
getRedirectResult(auth)
12+
.then((result) => {
13+
// User is signed in.
14+
// Provider data available from the result.user.getIdToken()
15+
// or from result.user.providerData
16+
})
17+
.catch((error) => {
18+
// Handle Errors here.
19+
const errorCode = error.code;
20+
const errorMessage = error.message;
21+
// The email of the user's account used.
22+
const email = error.email;
23+
// The AuthCredential type that was used.
24+
const credential = SAMLAuthProvider.credentialFromError(error);
25+
// Handle / display error.
26+
// ...
27+
});
28+
// [END auth_saml_signin_redirect_result_modular]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./auth/oidc.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_oidc_direct_sign_in_modular]
8+
const credential = provider.credential(oidcIdToken, null);
9+
10+
firebase.auth().signInWithCredential(credential)
11+
.then((result) => {
12+
// User is signed in.
13+
// User now has a odic.myProvider UserInfo in providerData.
14+
})
15+
.catch((error) => {
16+
// Handle / display error.
17+
// ...
18+
});
19+
// [END auth_oidc_direct_sign_in_modular]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./auth/oidc.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_oidc_provider_create_modular]
8+
const provider = new firebase.auth.OAuthProvider('oidc.myProvider');
9+
// [END auth_oidc_provider_create_modular]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./auth/oidc.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_oidc_signin_popup_modular]
8+
firebase.auth().signInWithPopup(provider)
9+
.then((result) => {
10+
// User is signed in.
11+
// result.credential is a firebase.auth().OAuthCredential object.
12+
// result.credential.providerId is equal to 'oidc.myProvider'.
13+
// result.credential.idToken is the OIDC provider's ID token.
14+
})
15+
.catch((error) => {
16+
// Handle error.
17+
});
18+
// [END auth_oidc_signin_popup_modular]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./auth/oidc.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_oidc_signin_redirect_modular]
8+
firebase.auth().signInWithRedirect(provider).catch((error) => {
9+
// Handle error.
10+
});
11+
// [END auth_oidc_signin_redirect_modular]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./auth/oidc.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_oidc_signin_redirect_result_modular]
8+
// On return.
9+
firebase.auth().getRedirectResult()
10+
.then((result) => {
11+
// User is signed in.
12+
// result.credential is a firebase.auth().OAuthCredential object.
13+
// result.credential.providerId is equal to 'oidc.myProvider'.
14+
// result.credential.idToken is the OIDC provider's ID token.
15+
})
16+
.catch((error) => {
17+
// Handle / display error.
18+
// ...
19+
});
20+
// [END auth_oidc_signin_redirect_result_modular]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./auth/saml.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_saml_provider_create_modular]
8+
const provider = new firebase.auth.SAMLAuthProvider('saml.myProvider');
9+
// [END auth_saml_provider_create_modular]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./auth/saml.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_saml_signin_popup_modular]
8+
firebase.auth().signInWithPopup(provider)
9+
.then((result) => {
10+
// User is signed in.
11+
// Identity provider data available in result.additionalUserInfo.profile,
12+
// or from the user's ID token obtained from result.user.getIdToken()
13+
// as an object in the firebase.sign_in_attributes custom claim
14+
// This is also available from result.user.getIdTokenResult()
15+
// idTokenResult.claims.firebase.sign_in_attributes.
16+
})
17+
.catch((error) => {
18+
// Handle / display error.
19+
// ...
20+
});
21+
// [END auth_saml_signin_popup_modular]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./auth/saml.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_saml_signin_redirect_modular]
8+
firebase.auth().signInWithRedirect(provider);
9+
// [END auth_saml_signin_redirect_modular]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./auth/saml.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_saml_signin_redirect_result_modular]
8+
firebase.auth().getRedirectResult()
9+
.then((result) => {
10+
// User is signed in.
11+
// Provider data available in result.additionalUserInfo.profile,
12+
// or from the user's ID token obtained from result.user.getIdToken()
13+
// as an object in the firebase.sign_in_attributes custom claim
14+
// This is also available from result.user.getIdTokenResult()
15+
// idTokenResult.claims.firebase.sign_in_attributes.
16+
}).catch((error) => {
17+
// Handle / display error.
18+
// ...
19+
});
20+
// [END auth_saml_signin_redirect_result_modular]

0 commit comments

Comments
 (0)