Skip to content

Commit

Permalink
add provider_credential snippets for the social Idps that don't have …
Browse files Browse the repository at this point in the history
…it. (#253)
  • Loading branch information
chronologos authored Oct 21, 2021
1 parent e2a9d33 commit 1c4c683
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 1 deletion.
9 changes: 9 additions & 0 deletions auth-next/facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,12 @@ function authWithCredential(credential) {
});
// [END auth_facebook_signin_credential]
}

function facebookProviderCredential(accessToken) {
// [START auth_facebook_provider_credential]
const { FacebookAuthProvider } = require("firebase/auth");

const credential = FacebookAuthProvider.credential(accessToken);
// [END auth_facebook_provider_credential]
}

9 changes: 9 additions & 0 deletions auth-next/google-signin.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,13 @@ function isUserEqual_wrapper() {
// [END auth_google_checksameuser]
}

function googleProviderCredential(idToken) {
// [START auth_google_provider_credential]
const { GoogleAuthProvider } = require("firebase/auth");

const credential = GoogleAuthProvider.credential(idToken);
// [END auth_google_provider_credential]
}



7 changes: 7 additions & 0 deletions auth-next/twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,10 @@ function twitterSignInRedirectResult() {
// [END auth_twitter_signin_redirect_result]
}

function twitterProviderCredential(accessToken, secret) {
// [START auth_twitter_provider_credential]
const { TwitterAuthProvider } = require("firebase/auth");

const credential = TwitterAuthProvider.credential(accessToken, secret);
// [END auth_twitter_provider_credential]
}
6 changes: 6 additions & 0 deletions auth/facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,9 @@ function authWithCredential(credential) {
});
// [END auth_facebook_signin_credential]
}

function facebookProviderCredential(accessToken) {
// [START auth_facebook_provider_credential]
var credential = firebase.auth.FacebookAuthProvider.credential(accessToken);
// [END auth_facebook_provider_credential]
}
6 changes: 6 additions & 0 deletions auth/google-signin.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,9 @@ function isUserEqual(googleUser, firebaseUser) {
return false;
}
// [END auth_google_checksameuser]

function googleProviderCredential(idToken) {
// [START auth_google_provider_credential]
var credential = firebase.auth.GoogleAuthProvider.credential(idToken);
// [END auth_google_provider_credential]
}
9 changes: 9 additions & 0 deletions auth/initialization.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script src="https://www.gstatic.com/firebasejs/x.x.x/firebase.js"></script>
<script>
// Initialize Auth
const config = {
apiKey: "...",
authDomain: "my-app-12345.firebaseapp.com"
};
firebase.initializeApp(config);
</script>
2 changes: 1 addition & 1 deletion auth/multi-tenancy.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function switchTenantSingleAuth() {
// [END multitenant_switch_tenant]
}

function switchTenantMultiAuthInstance(config) {
function switchTenantMultiAuth(config) {
// [START multitenant_switch_tenant_multiinstance]
// Multiple Auth instances
firebase.initializeApp(config, 'app1_for_tenantId1');
Expand Down
6 changes: 6 additions & 0 deletions auth/twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,9 @@ function twitterSignInRedirectResult() {
});
// [END auth_twitter_signin_redirect_result]
}

function twitterProviderCredential(accessToken, secret) {
// [START auth_twitter_provider_credential]
var credential = firebase.auth.TwitterAuthProvider.credential(accessToken, secret);
// [END auth_twitter_provider_credential]
}
11 changes: 11 additions & 0 deletions snippets/auth-next/facebook/auth_facebook_provider_credential.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This snippet file was generated by processing the source file:
// ./auth-next/facebook.js
//
// To update the snippets in this file, edit the source and then run
// 'npm run snippets'.

// [START auth_facebook_provider_credential_modular]
import { FacebookAuthProvider } from "firebase/auth";

const credential = FacebookAuthProvider.credential(accessToken);
// [END auth_facebook_provider_credential_modular]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This snippet file was generated by processing the source file:
// ./auth-next/google-signin.js
//
// To update the snippets in this file, edit the source and then run
// 'npm run snippets'.

// [START auth_google_provider_credential_modular]
import { GoogleAuthProvider } from "firebase/auth";

const credential = GoogleAuthProvider.credential(idToken);
// [END auth_google_provider_credential_modular]
11 changes: 11 additions & 0 deletions snippets/auth-next/twitter/auth_twitter_provider_credential.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This snippet file was generated by processing the source file:
// ./auth-next/twitter.js
//
// To update the snippets in this file, edit the source and then run
// 'npm run snippets'.

// [START auth_twitter_provider_credential_modular]
import { TwitterAuthProvider } from "firebase/auth";

const credential = TwitterAuthProvider.credential(accessToken, secret);
// [END auth_twitter_provider_credential_modular]

0 comments on commit 1c4c683

Please sign in to comment.