Skip to content

Commit c5c5ed6

Browse files
committed
No longer pass client ID into Google API Client
Fixes #41 Also raise error is sign-in result is not a success.
1 parent 2de7ca6 commit c5c5ed6

File tree

2 files changed

+6
-35
lines changed

2 files changed

+6
-35
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@
3939
android:name="com.facebook.sdk.ApplicationId"
4040
android:value="@string/facebook_app_id" />
4141

42-
<!-- Google Configuration -->
43-
<meta-data
44-
android:name="com.firebase.ui.GoogleClientId"
45-
android:value="@string/google_client_id" />
46-
47-
4842
</application>
4943

5044
</manifest>

library/src/main/java/com/firebase/ui/auth/google/GoogleAuthProvider.java

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import android.app.Activity;
44
import android.content.Context;
55
import android.content.Intent;
6-
import android.content.pm.ApplicationInfo;
7-
import android.content.pm.PackageManager;
86
import android.os.Bundle;
97
import android.support.v4.app.FragmentActivity;
108
import android.util.Log;
@@ -44,33 +42,7 @@ public GoogleAuthProvider(Context context, Firebase ref, TokenAuthHandler handle
4442
mRef = ref;
4543
mHandler = handler;
4644

47-
String googleClientId = "";
48-
49-
try {
50-
ApplicationInfo ai = mActivity.getPackageManager().getApplicationInfo(mActivity.getPackageName(), PackageManager.GET_META_DATA);
51-
Bundle bundle = ai.metaData;
52-
googleClientId = bundle.getString("com.firebase.ui.GoogleClientId");
53-
} catch (PackageManager.NameNotFoundException e) {
54-
} catch (NullPointerException e) {}
55-
56-
if (googleClientId == null) {
57-
FirebaseLoginError error = new FirebaseLoginError(
58-
FirebaseResponse.MISSING_PROVIDER_APP_KEY,
59-
"Missing Google client ID, is it set in your AndroidManifest.xml?");
60-
mHandler.onProviderError(error);
61-
return;
62-
}
63-
64-
if (googleClientId.compareTo("") == 0) {
65-
FirebaseLoginError error = new FirebaseLoginError(
66-
FirebaseResponse.INVALID_PROVIDER_APP_KEY,
67-
"Invalid Google client ID, is it set in your res/values/strings.xml?");
68-
mHandler.onProviderError(error);
69-
return;
70-
}
71-
7245
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
73-
.requestIdToken(googleClientId)
7446
.requestEmail()
7547
.build();
7648

@@ -99,7 +71,9 @@ public void onConnected(Bundle bundle) {
9971
}
10072

10173
@Override
102-
public void onConnectionSuspended(int i) {}
74+
public void onConnectionSuspended(int i) {
75+
76+
}
10377

10478
public void logout() {
10579
if (mGoogleApiClient.isConnected()) {
@@ -154,6 +128,9 @@ private void handleSignInResult(GoogleSignInResult result) {
154128
googleOAuthTask.setHandler(this);
155129
googleOAuthTask.execute(acct.getEmail());
156130
}
131+
else {
132+
mHandler.onProviderError(new FirebaseLoginError(FirebaseResponse.MISC_PROVIDER_ERROR, result.getStatus().toString()));
133+
}
157134
}
158135

159136

0 commit comments

Comments
 (0)