Skip to content

Commit 1c4c683

Browse files
authored
add provider_credential snippets for the social Idps that don't have it. (#253)
1 parent e2a9d33 commit 1c4c683

11 files changed

+86
-1
lines changed

auth-next/facebook.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,12 @@ function authWithCredential(credential) {
163163
});
164164
// [END auth_facebook_signin_credential]
165165
}
166+
167+
function facebookProviderCredential(accessToken) {
168+
// [START auth_facebook_provider_credential]
169+
const { FacebookAuthProvider } = require("firebase/auth");
170+
171+
const credential = FacebookAuthProvider.credential(accessToken);
172+
// [END auth_facebook_provider_credential]
173+
}
174+

auth-next/google-signin.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,13 @@ function isUserEqual_wrapper() {
157157
// [END auth_google_checksameuser]
158158
}
159159

160+
function googleProviderCredential(idToken) {
161+
// [START auth_google_provider_credential]
162+
const { GoogleAuthProvider } = require("firebase/auth");
163+
164+
const credential = GoogleAuthProvider.credential(idToken);
165+
// [END auth_google_provider_credential]
166+
}
167+
168+
160169

auth-next/twitter.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,10 @@ function twitterSignInRedirectResult() {
7373
// [END auth_twitter_signin_redirect_result]
7474
}
7575

76+
function twitterProviderCredential(accessToken, secret) {
77+
// [START auth_twitter_provider_credential]
78+
const { TwitterAuthProvider } = require("firebase/auth");
79+
80+
const credential = TwitterAuthProvider.credential(accessToken, secret);
81+
// [END auth_twitter_provider_credential]
82+
}

auth/facebook.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,9 @@ function authWithCredential(credential) {
151151
});
152152
// [END auth_facebook_signin_credential]
153153
}
154+
155+
function facebookProviderCredential(accessToken) {
156+
// [START auth_facebook_provider_credential]
157+
var credential = firebase.auth.FacebookAuthProvider.credential(accessToken);
158+
// [END auth_facebook_provider_credential]
159+
}

auth/google-signin.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,9 @@ function isUserEqual(googleUser, firebaseUser) {
142142
return false;
143143
}
144144
// [END auth_google_checksameuser]
145+
146+
function googleProviderCredential(idToken) {
147+
// [START auth_google_provider_credential]
148+
var credential = firebase.auth.GoogleAuthProvider.credential(idToken);
149+
// [END auth_google_provider_credential]
150+
}

auth/initialization.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<script src="https://www.gstatic.com/firebasejs/x.x.x/firebase.js"></script>
2+
<script>
3+
// Initialize Auth
4+
const config = {
5+
apiKey: "...",
6+
authDomain: "my-app-12345.firebaseapp.com"
7+
};
8+
firebase.initializeApp(config);
9+
</script>

auth/multi-tenancy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function switchTenantSingleAuth() {
2323
// [END multitenant_switch_tenant]
2424
}
2525

26-
function switchTenantMultiAuthInstance(config) {
26+
function switchTenantMultiAuth(config) {
2727
// [START multitenant_switch_tenant_multiinstance]
2828
// Multiple Auth instances
2929
firebase.initializeApp(config, 'app1_for_tenantId1');

auth/twitter.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,9 @@ function twitterSignInRedirectResult() {
7676
});
7777
// [END auth_twitter_signin_redirect_result]
7878
}
79+
80+
function twitterProviderCredential(accessToken, secret) {
81+
// [START auth_twitter_provider_credential]
82+
var credential = firebase.auth.TwitterAuthProvider.credential(accessToken, secret);
83+
// [END auth_twitter_provider_credential]
84+
}
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/facebook.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_facebook_provider_credential_modular]
8+
import { FacebookAuthProvider } from "firebase/auth";
9+
10+
const credential = FacebookAuthProvider.credential(accessToken);
11+
// [END auth_facebook_provider_credential_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/google-signin.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_google_provider_credential_modular]
8+
import { GoogleAuthProvider } from "firebase/auth";
9+
10+
const credential = GoogleAuthProvider.credential(idToken);
11+
// [END auth_google_provider_credential_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/twitter.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START auth_twitter_provider_credential_modular]
8+
import { TwitterAuthProvider } from "firebase/auth";
9+
10+
const credential = TwitterAuthProvider.credential(accessToken, secret);
11+
// [END auth_twitter_provider_credential_modular]

0 commit comments

Comments
 (0)