Skip to content

Commit 9a7a10f

Browse files
author
Jiachen Zhao
committed
Change API interface to take in FirebaseApp instance directly to remove the need for user to provide apiKey, appName and applicationId separately
Change-Id: Id45e817e188e80a4b9e1bcf865d28dbf86fa8189
1 parent 2f95e75 commit 9a7a10f

File tree

3 files changed

+12
-38
lines changed

3 files changed

+12
-38
lines changed

auth/src/main/java/com/firebase/ui/auth/AuthFlowFactory.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.firebase.ui.auth.choreographer.idp.provider.GoogleProvider;
2424
import com.firebase.ui.auth.choreographer.idp.provider.IDPProviderParcel;
2525
import com.firebase.ui.auth.ui.credentials.CredentialsInitActivity;
26+
import com.google.firebase.FirebaseApp;
2627

2728
import java.util.ArrayList;
2829
import java.util.List;
@@ -34,21 +35,23 @@ public class AuthFlowFactory {
3435
/**
3536
* Creates the intent that starts the auth flow
3637
* @param context activity context
37-
* @param appName the app name of the FirebaseApp that you wish to use
38-
* @param apiaryKey the Firebase backend API key
39-
* @param applicationId the Firebase application id
40-
* @param providers the supported identity providers that you wish to enable (google, facebook, etc)
41-
* @return the Intent to start the auth flow
38+
* @param firebaseApp the FirebaseApp that's to used for the authentication flow
39+
* @param termsOfServiceUrl the URL to the Term of Service page to be present to the user
40+
* @param theme the customized theme to be applied to the authentication flow. 0 will use the default theme.
41+
* @param providers the supported identity providers that you wish to enable (google, facebook, etc)
42+
* @return
4243
*/
4344
public static Intent createIntent(
45+
// * @param providers the supported identity providers that you wish to enable (google, facebook, etc)
4446
@NonNull Context context,
45-
@NonNull String appName,
46-
@NonNull String apiaryKey,
47-
@NonNull String applicationId,
47+
@NonNull FirebaseApp firebaseApp,
4848
String termsOfServiceUrl,
4949
int theme,
5050
@Nullable List<String> providers) {
5151
ArrayList<IDPProviderParcel> providerParcels = new ArrayList<>();
52+
String appName = firebaseApp.getName();
53+
String apiaryKey = firebaseApp.getOptions().getApiKey();
54+
String applicationId = firebaseApp.getOptions().getApplicationId();
5255
if (providers == null || providers.size() == 0) {
5356
return CredentialsInitActivity.createIntent(
5457
context,
@@ -67,7 +70,7 @@ public static Intent createIntent(
6770
context.getString(R.string.facebook_application_id)));
6871
} else if (provider.equalsIgnoreCase("google")) {
6972
providerParcels.add(
70-
GoogleProvider.createParcel(context.getString(R.string.google_client_id)));
73+
GoogleProvider.createParcel(firebaseApp.getOptions().getApplicationId()));
7174
}
7275
}
7376
return CredentialsInitActivity.createIntent(

auth/src/main/java/com/firebase/ui/auth/api/FirebaseAuthWrapperFactory.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,4 @@ public static FirebaseAuthWrapper getFirebaseAuthWrapper(String appName) {
3434
public static FirebaseAuthWrapper getFirebaseAuthWrapper(FirebaseApp firebaseApp) {
3535
return new FirebaseAuthWrapperImpl(FirebaseAuth.getInstance(firebaseApp));
3636
}
37-
38-
public static FirebaseAuthWrapper getFirebaseAuthWrapper(
39-
Context context, String appName, JSONObject mGoogleServiceJSON) {
40-
// TODO(zhaojiac): change this to use Google Services plugin instead
41-
String apiaryKey =
42-
mGoogleServiceJSON
43-
.optJSONArray("client")
44-
.optJSONObject(1)
45-
.optJSONArray("api_key")
46-
.optJSONObject(0)
47-
.optString("current_key");
48-
String applicationId =
49-
mGoogleServiceJSON
50-
.optJSONArray("client")
51-
.optJSONObject(1)
52-
.optJSONArray("oauth_client")
53-
.optJSONObject(0)
54-
.optString("client_id");
55-
FirebaseOptions options
56-
= new FirebaseOptions.Builder()
57-
.setApiKey(apiaryKey)
58-
.setApplicationId(applicationId)
59-
.build();
60-
FirebaseApp curApp = FirebaseApp.initializeApp(context, options, appName);
61-
return new FirebaseAuthWrapperImpl(FirebaseAuth.getInstance(curApp));
62-
}
6337
}

auth/src/main/res/values/strings.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,4 @@
6262
<string name="progress_dialog_signing_in">Signing in…</string>
6363
<string name="progress_dialog_signing_up">Signing up…</string>
6464
<string name="facebook_application_id">FACEBOOK-APPID</string>
65-
<string name="google_client_id">GOOGLE-CLIENT-ID</string>
66-
67-
6865
</resources>

0 commit comments

Comments
 (0)