Skip to content

Commit

Permalink
fix(auth): return email address if one is returned by the auth except…
Browse files Browse the repository at this point in the history
…ion (#11978)
  • Loading branch information
russellwheatley committed Dec 12, 2023
1 parent 2712ea4 commit ceee304
Show file tree
Hide file tree
Showing 12 changed files with 162 additions and 156 deletions.
Expand Up @@ -36,7 +36,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "io.flutter.plugins.firebase.auth.example"
minSdk 19
minSdk 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down Expand Up @@ -70,7 +70,6 @@ flutter {
}

dependencies {
implementation 'com.android.support:multidex:2.0.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

Expand Down
@@ -1,42 +1,49 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:usesCleartextTraffic="true"
android:label="Firebase Auth"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "example://gizmos” -->
<!-- Registered Callback URLs in TwitterApp -->
<data android:scheme="flutterfireauth" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
<application
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:label="Firebase Auth"
android:usesCleartextTraffic="true">
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<meta-data
android:name="com.facebook.sdk.ClientToken"
android:value="@string/facebook_client_token" />
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "example://gizmos” -->
<!-- Registered Callback URLs in TwitterApp -->
<data android:scheme="flutterfireauth" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="facebook_app_id">128693022464535</string>
<!-- The Facebook client token should not be made public but this is a developer mode app with whitelisted user access -->
<string name="facebook_client_token">16dbbdf0cfb309034a6ad98ac2a21688</string>
</resources>
Expand Up @@ -174,12 +174,11 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "The Chromium Authors";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = YYX2P3XVJ7;
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -292,7 +291,16 @@
"${BUILT_PRODUCTS_DIR}/GoogleSignIn/GoogleSignIn.framework",
"${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework",
"${BUILT_PRODUCTS_DIR}/PromisesObjC/FBLPromises.framework",
"${BUILT_PRODUCTS_DIR}/RecaptchaInterop/RecaptchaInterop.framework",
"${BUILT_PRODUCTS_DIR}/flutter_facebook_auth/flutter_facebook_auth.framework",
"${BUILT_PRODUCTS_DIR}/flutter_secure_storage/flutter_secure_storage.framework",
"${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
"${BUILT_PRODUCTS_DIR}/shared_preferences_foundation/shared_preferences_foundation.framework",
"${BUILT_PRODUCTS_DIR}/url_launcher_ios/url_launcher_ios.framework",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/FBAEMKit/FBAEMKit.framework/FBAEMKit",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/FBSDKCoreKit/FBSDKCoreKit.framework/FBSDKCoreKit",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/FBSDKCoreKit_Basics/FBSDKCoreKit_Basics.framework/FBSDKCoreKit_Basics",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/FBSDKLoginKit/FBSDKLoginKit.framework/FBSDKLoginKit",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
Expand All @@ -309,7 +317,16 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleSignIn.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBLPromises.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RecaptchaInterop.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_facebook_auth.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_secure_storage.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences_foundation.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_ios.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBAEMKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBSDKCoreKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBSDKCoreKit_Basics.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBSDKLoginKit.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Expand Up @@ -22,6 +22,11 @@
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>FacebookAppID</key>
<string>128693022464535</string>
<!-- The Facebook client token should not be made public but this is a developer mode app with whitelisted user access -->
<key>FacebookClientToken</key>
<string>16dbbdf0cfb309034a6ad98ac2a21688</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand All @@ -30,6 +35,7 @@
<key>CFBundleURLSchemes</key>
<array>
<string>com.googleusercontent.apps.406099696497-134k3722m01rtrsklhf3b7k8sqa5r7in</string>
<string>fb128693022464535</string>
</array>
</dict>
</array>
Expand Down
100 changes: 62 additions & 38 deletions packages/firebase_auth/firebase_auth/example/lib/auth.dart
Expand Up @@ -14,6 +14,7 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_signin_button/flutter_signin_button.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';

typedef OAuthSignIn = void Function();

Expand Down Expand Up @@ -123,6 +124,9 @@ class _AuthGateState extends State<AuthGate> {
Buttons.Yahoo: () => _handleMultiFactorException(
_signInWithYahoo,
),
Buttons.Facebook: () => _handleMultiFactorException(
_signInWithFacebook,
),
};
}
}
Expand Down Expand Up @@ -558,59 +562,79 @@ class _AuthGateState extends State<AuthGate> {
}
}

Future<void> _signInWithTwitter() async {
TwitterAuthProvider twitterProvider = TwitterAuthProvider();
Future<void> _signInWithFacebook() async {
// Trigger the authentication flow
// by default we request the email and the public profile
final LoginResult result = await FacebookAuth.instance.login();

if (result.status == LoginStatus.success) {
// Get access token
final AccessToken accessToken = result.accessToken!;

if (kIsWeb) {
await auth.signInWithPopup(twitterProvider);
// Login with token
await auth.signInWithCredential(
FacebookAuthProvider.credential(accessToken.token),
);
} else {
await auth.signInWithProvider(twitterProvider);
print('Facebook login did not succeed');
print(result.status);
print(result.message);
}
}
}

Future<void> _signInWithApple() async {
final appleProvider = AppleAuthProvider();
appleProvider.addScope('email');
Future<void> _signInWithTwitter() async {
TwitterAuthProvider twitterProvider = TwitterAuthProvider();

if (kIsWeb) {
// Once signed in, return the UserCredential
await auth.signInWithPopup(appleProvider);
} else {
final userCred = await auth.signInWithProvider(appleProvider);
AuthGate.appleAuthorizationCode =
userCred.additionalUserInfo?.authorizationCode;
}
if (kIsWeb) {
await auth.signInWithPopup(twitterProvider);
} else {
await auth.signInWithProvider(twitterProvider);
}
}

Future<void> _signInWithYahoo() async {
final yahooProvider = YahooAuthProvider();
Future<void> _signInWithApple() async {
final appleProvider = AppleAuthProvider();
appleProvider.addScope('email');

if (kIsWeb) {
// Once signed in, return the UserCredential
await auth.signInWithPopup(appleProvider);
} else {
final userCred = await auth.signInWithProvider(appleProvider);
AuthGate.appleAuthorizationCode =
userCred.additionalUserInfo?.authorizationCode;
}
}

if (kIsWeb) {
// Once signed in, return the UserCredential
await auth.signInWithPopup(yahooProvider);
} else {
await auth.signInWithProvider(yahooProvider);
}
Future<void> _signInWithYahoo() async {
final yahooProvider = YahooAuthProvider();

if (kIsWeb) {
// Once signed in, return the UserCredential
await auth.signInWithPopup(yahooProvider);
} else {
await auth.signInWithProvider(yahooProvider);
}
}

Future<void> _signInWithGitHub() async {
final githubProvider = GithubAuthProvider();
Future<void> _signInWithGitHub() async {
final githubProvider = GithubAuthProvider();

if (kIsWeb) {
await auth.signInWithPopup(githubProvider);
} else {
await auth.signInWithProvider(githubProvider);
}
if (kIsWeb) {
await auth.signInWithPopup(githubProvider);
} else {
await auth.signInWithProvider(githubProvider);
}
}

Future<void> _signInWithMicrosoft() async {
final microsoftProvider = MicrosoftAuthProvider();
Future<void> _signInWithMicrosoft() async {
final microsoftProvider = MicrosoftAuthProvider();

if (kIsWeb) {
await auth.signInWithPopup(microsoftProvider);
} else {
await auth.signInWithProvider(microsoftProvider);
}
if (kIsWeb) {
await auth.signInWithPopup(microsoftProvider);
} else {
await auth.signInWithProvider(microsoftProvider);
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/firebase_auth/firebase_auth/example/pubspec.yaml
Expand Up @@ -11,6 +11,7 @@ dependencies:
firebase_messaging: ^14.7.8
flutter:
sdk: flutter
flutter_facebook_auth: ^5.0.11
flutter_signin_button: ^2.0.0
google_sign_in: ^6.1.0
google_sign_in_dartio: ^0.2.2+1 # For Windows support
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit ceee304

Please sign in to comment.