Social Authentication
Notice
This page is archived and might not reflect the latest version of the FlutterFire plugins. You can find the latest information on firebase.google.com:
https://firebase.google.com/docs/auth/flutter/federated-auth
Social authentication is a multi-step authentication flow, allowing you to sign a user into an account or link them with an existing one.
Both native platforms and web support creating a credential which can then be passed to the signInWithCredential
or linkWithCredential
methods. Alternatively on web platforms, you can trigger the authentication process via
a popup or redirect.
#
GoogleMost configuration is already setup when using Google Sign-In with Firebase, however you need to ensure your machine's SHA1 key has been configured for use with Android. You can see how to generate the key on the Installation documentation.
Ensure the "Google" sign-in provider is enabled on the Firebase Console.
If your user signs in with Google, after having already manually registered an account, their authentication provider will automatically change to Google, due to Firebase Authentications concept of trusted providers. You can find out more about this here.
- Native
- Web
On native platforms, a 3rd party library is required to trigger the authentication flow.
Install the official google_sign_in
plugin:
caution
Dart-only Firebase initialization isn't yet supported by google_sign_in
plugin, if you're using Google as an auth provider you'll still have to do the manual installation steps to integrate the Firebase configuration files.
Once installed, trigger the sign-in flow and create a new credential:
On the web, the Firebase SDK provides support for automatically handling the authentication flow using your Firebase project. For example:
Create a Google auth provider, providing any additional permission scope you wish to obtain from the user:
Provide the credential to the signInWithPopup
method. This will trigger a new
window to appear prompting the user to sign-in to your project. Alternatively you can use signInWithRedirect
to keep the
authentication process in the same window.
#
FacebookBefore getting started setup your Facebook Developer App and follow the setup process to enable Facebook Login.
Ensure the "Facebook" sign-in provider is enabled on the Firebase Console. with the Facebook App ID and Secret set.
- Native
- Web
On native platforms, a 3rd party library is required to both install the Facebook SDK and trigger the authentication flow.
Install the flutter_facebook_auth
plugin:
You will need to follow the steps in the plugin documentation to ensure that both the Android & iOS Facebook SDKs have been initialized correctly. Once complete, trigger the sign-in flow, create a Facebook credential and sign the user in:
On the web, the Firebase SDK provides support for automatically handling the authentication flow using the Facebook application details provided on the Firebase console. For example:
Create a Facebook provider, providing any additional permission scope you wish to obtain from the user.
Ensure that the OAuth redirect URI from the Firebase console is added as a valid OAuth Redirect URI in your Facebook App.
Provide the credential to the signInWithPopup
method. This will trigger a new
window to appear prompting the user to sign-in to your Facebook application:
caution
Firebase will not set the User.emailVerified
property
to true
if your user logs in with Facebook. Should your user login using a provider that verifies email (e.g. Google sign-in) then this will be set to true.
For further information, see this issue.
#
AppleApple announced that any applications using 3rd party login services (such as Facebook, Twitter, Google etc) must also have an Apple Sign-In method. Apple Sign-In is not required for Android devices.
- iOS/macOS
- Android
- Web
Before you begin configure Sign In with Apple and enable Apple as a sign-in provider.
Next, make sure that your Runner
apps have the "Sign in with Apple" capability.
Install the sign_in_with_apple
plugin, as well as the
crypto
package:
At the moment, the preferable solution is blocked by this issue.
Before you begin configure Sign In with Apple and enable Apple as a sign-in provider.
An alternative is to use signInWithRedirect
. In that case the browser will navigate away from your app
and you have to use getRedirectResult
to check for authentication results during app startup.
#
TwitterEnsure the "Twitter" sign-in provider is enabled on the Firebase Console with an API Key and API Secret set.
- Native
- Web
On native platforms, a 3rd party library is required to both install the Twitter SDK and trigger the authentication flow.
Install the twitter_login
plugin:
Make sure to carefully go through the configuration steps of twitter_login
and register a callback URL at the Twitter Developer Portal with a matching URL scheme
On the web, the Twitter SDK provides support for automatically handling the authentication flow using the Twitter application details provided on the Firebase console. Ensure that the callback URL in the Firebase console is added as a callback URL in your Twitter application on their developer console.
For example:
Create a Twitter provider and provide the credential to the signInWithPopup
method. This will trigger a new
window to appear prompting the user to sign-in to your Twitter application:
#
GitHubEnsure that you have setup an OAuth App from your GitHub Developer Settings and that the "GitHub" sign-in provider is enabled on the Firebase Console with the Client ID and Secret are set, with the callback URL set in the GitHub app.
- Native
- Web
On native platforms, a 3rd party library is required to both install the GitHub SDK and trigger the authentication flow.
Install the github_sign_in
plugin:
You will need to populate the GitHubSignIn
instance with your GitHub Client ID, GitHub Client Secret and also a Redirect URL (Firebase callback url).
Once complete trigger the sign-in flow, create a GitHub credential and sign the user in:
On the web, the GitHub SDK provides support for automatically handling the authentication flow using the GitHub application details provided on the Firebase console. Ensure that the callback URL in the Firebase console is added as a callback URL in your GitHub application on the developer console.
For example:
Create a GitHub provider and provide the credential to the signInWithPopup
method. This will trigger a new
window to appear prompting the user to sign-in to your GitHub application: