Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove TwitterSignInHandler because its dependency TwitterKit is deprecated #1627

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ dependencies {
// Needed to override Facebook
implementation(Config.Libs.Support.cardView)
implementation(Config.Libs.Support.customTabs)
implementation(Config.Libs.Provider.twitter) { isTransitive = true }

implementation(Config.Libs.Misc.glide)
annotationProcessor(Config.Libs.Misc.glideCompiler)
Expand Down
13 changes: 0 additions & 13 deletions app/src/main/java/com/firebase/uidemo/auth/AuthUiActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public class AuthUiActivity extends AppCompatActivity {

@BindView(R.id.google_provider) CheckBox mUseGoogleProvider;
@BindView(R.id.facebook_provider) CheckBox mUseFacebookProvider;
@BindView(R.id.twitter_provider) CheckBox mUseTwitterProvider;
@BindView(R.id.github_provider) CheckBox mUseGitHubProvider;
@BindView(R.id.email_provider) CheckBox mUseEmailProvider;
@BindView(R.id.email_link_provider) CheckBox mUseEmailLinkProvider;
Expand Down Expand Up @@ -151,12 +150,6 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
});
}

if (ConfigurationUtils.isTwitterMisconfigured(this)) {
mUseTwitterProvider.setChecked(false);
mUseTwitterProvider.setEnabled(false);
mUseTwitterProvider.setText(R.string.twitter_label_missing_config);
}

if (ConfigurationUtils.isGitHubMisconfigured(this)) {
mUseGitHubProvider.setChecked(false);
mUseGitHubProvider.setEnabled(false);
Expand Down Expand Up @@ -198,7 +191,6 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
mUseEmailProvider.setChecked(true);

mUseFacebookProvider.setChecked(false);
mUseTwitterProvider.setChecked(false);
mUseGitHubProvider.setChecked(false);
mUseEmailLinkProvider.setChecked(false);
mUsePhoneProvider.setChecked(false);
Expand All @@ -209,7 +201,6 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {

if (ConfigurationUtils.isGoogleMisconfigured(this)
|| ConfigurationUtils.isFacebookMisconfigured(this)
|| ConfigurationUtils.isTwitterMisconfigured(this)
|| ConfigurationUtils.isGitHubMisconfigured(this)) {
showSnackbar(R.string.configuration_required);
}
Expand Down Expand Up @@ -405,10 +396,6 @@ private List<IdpConfig> getSelectedProviders() {
.build());
}

if (mUseTwitterProvider.isChecked()) {
selectedProviders.add(new IdpConfig.TwitterBuilder().build());
}

if (mUseGitHubProvider.isChecked()) {
selectedProviders.add(new IdpConfig.GitHubBuilder()
.setPermissions(getGitHubPermissions())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import com.google.firebase.auth.GithubAuthProvider;
import com.google.firebase.auth.GoogleAuthProvider;
import com.google.firebase.auth.PhoneAuthProvider;
import com.google.firebase.auth.TwitterAuthProvider;
import com.google.firebase.auth.UserInfo;

import java.util.ArrayList;
Expand Down Expand Up @@ -177,9 +176,6 @@ private void populateProfile(@Nullable IdpResponse response) {
case FacebookAuthProvider.PROVIDER_ID:
providers.add(getString(R.string.providers_facebook));
break;
case TwitterAuthProvider.PROVIDER_ID:
providers.add(getString(R.string.providers_twitter));
break;
case GithubAuthProvider.PROVIDER_ID:
providers.add(getString(R.string.providers_github));
break;
Expand Down Expand Up @@ -210,7 +206,6 @@ private void populateIdpToken(@Nullable IdpResponse response) {
String secret = null;
if (response != null) {
token = response.getIdpToken();
secret = response.getIdpSecret();
}

View idpTokenLayout = findViewById(R.id.idp_token_layout);
Expand Down
13 changes: 0 additions & 13 deletions app/src/main/java/com/firebase/uidemo/util/ConfigurationUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ public static boolean isFacebookMisconfigured(@NonNull Context context) {
context.getString(R.string.facebook_application_id));
}

public static boolean isTwitterMisconfigured(@NonNull Context context) {
List<String> twitterConfigs = Arrays.asList(
context.getString(R.string.twitter_consumer_key),
context.getString(R.string.twitter_consumer_secret)
);

return twitterConfigs.contains(AuthUI.UNCONFIGURED_CONFIG_VALUE);
}

public static boolean isGitHubMisconfigured(@NonNull Context context) {
List<String> gitHubConfigs = Arrays.asList(
context.getString(R.string.firebase_web_host),
Expand All @@ -59,10 +50,6 @@ public static List<AuthUI.IdpConfig> getConfiguredProviders(@NonNull Context con
providers.add(new AuthUI.IdpConfig.FacebookBuilder().build());
}

if (!isTwitterMisconfigured(context)) {
providers.add(new AuthUI.IdpConfig.TwitterBuilder().build());
}

if (!isGitHubMisconfigured(context)) {
providers.add(new AuthUI.IdpConfig.GitHubBuilder().build());
}
Expand Down
7 changes: 0 additions & 7 deletions app/src/main/res/layout/auth_ui_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@
android:checked="true"
android:text="@string/providers_facebook" />

<CheckBox
android:id="@+id/twitter_provider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/providers_twitter" />

<CheckBox
android:id="@+id/github_provider"
android:layout_width="wrap_content"
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/res/values/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
<string name="facebook_application_id" translatable="false">CHANGE-ME</string>
<string name="facebook_login_protocol_scheme" translatable="false">fbYOUR_APP_ID</string>

<string name="twitter_consumer_key" translatable="false">CHANGE-ME</string>
<string name="twitter_consumer_secret" translatable="false">CHANGE-ME</string>

<string name="github_client_id" translatable="false">CHANGE-ME</string>
<string name="github_client_secret" translatable="false">CHANGE-ME</string>
</resources>
2 changes: 0 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<string name="providers_google">Google</string>
<string name="providers_facebook">Facebook</string>
<string name="providers_github">GitHub</string>
<string name="providers_twitter">Twitter</string>
<string name="providers_email">Email</string>
<string name="providers_email_link">Email link</string>
<string name="providers_phone">Phone</string>
Expand Down Expand Up @@ -71,7 +70,6 @@
<string name="configuration_required">Configuration required - see README.md</string>
<string name="google_label_missing_config">Google configuration missing</string>
<string name="facebook_label_missing_config">Facebook configuration missing</string>
<string name="twitter_label_missing_config">Twitter configuration missing</string>
<string name="github_label_missing_config">GitHub configuration missing</string>

<string name="sign_in_cancelled">Sign in cancelled</string>
Expand Down
41 changes: 1 addition & 40 deletions auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ and [Web](https://github.com/firebase/firebaseui-web/).
1. [OAuth scopes](#oauth-scope-customization)
1. [Google](#google-1)
1. [Facebook](#facebook-1)
1. [Twitter](#twitter-1)
1. [GitHub](#github-1)

## Demo
Expand All @@ -74,10 +73,6 @@ dependencies {
// Required only if Facebook login support is required
// Find the latest Facebook SDK releases here: https://goo.gl/Ce5L94
implementation 'com.facebook.android:facebook-login:4.x'

// Required only if Twitter login support is required
// Find the latest Twitter SDK releases here: https://goo.gl/E5wZvQ
implementation("com.twitter.sdk.android:twitter-core:3.x@aar") { transitive = true }
}
```

Expand All @@ -101,7 +96,7 @@ for more information.

### Identity provider configuration

In order to use either Google, Facebook or Twitter accounts with your app, ensure that
In order to use either Google, or Facebook accounts with your app, ensure that
these authentication methods are first configured in the Firebase console.

#### Google
Expand All @@ -125,33 +120,6 @@ the [Facebook developer dashboard](https://developers.facebook.com):
</resources>
```

#### Twitter

If support for Twitter Sign-in is also required, define the resource strings
`twitter_consumer_key` and `twitter_consumer_secret` to match the values of your
Twitter app as reported by the [Twitter application manager](https://apps.twitter.com/).

```xml
<resources>
<string name="twitter_consumer_key" translatable="false">YOUR_CONSUMER_KEY</string>
<string name="twitter_consumer_secret" translatable="false">YOUR_CONSUMER_SECRET</string>
</resources>
```

In addition, you must enable the "Request email addresses from users" permission
in the "Permissions" tab of your Twitter app.

In order to resolve the Twitter SDK, add the following repository to your `build.gradle`:

```groovy
allprojects {
repositories {
// ...
maven { url 'https://maven.fabric.io/public' }
}
}
```

#### GitHub

WARNING: GitHub OAuth is not for the faint of heart. Getting it setup correctly is an invested
Expand Down Expand Up @@ -329,7 +297,6 @@ startActivityForResult(
.setAvailableProviders(Arrays.asList(
new AuthUI.IdpConfig.GoogleBuilder().build(),
new AuthUI.IdpConfig.FacebookBuilder().build(),
new AuthUI.IdpConfig.TwitterBuilder().build(),
new AuthUI.IdpConfig.GitHubBuilder().build(),
new AuthUI.IdpConfig.EmailBuilder().build(),
new AuthUI.IdpConfig.PhoneBuilder().build(),
Expand Down Expand Up @@ -596,8 +563,6 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
```

Twitter also returns an AuthToken Secret which can be accessed with `idpResponse.getIdpSecret()`.

#### User metadata

While `IdpResponse` provides user information about a specific sign-in instance, it is usually
Expand Down Expand Up @@ -956,10 +921,6 @@ startActivityForResult(
RC_SIGN_IN);
```

### Twitter

Twitter permissions can only be configured through [Twitter's developer console](https://apps.twitter.com/).

### GitHub

By default, FirebaseUI requests the `user:email` permission when performing OAuth. If you would like
Expand Down
3 changes: 0 additions & 3 deletions auth/auth-proguard.pro
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# 3P providers are optional
-dontwarn com.facebook.**
-dontwarn com.twitter.**
# Keep the class names used to check for availablility
-keepnames class com.facebook.login.LoginManager
-keepnames class com.twitter.sdk.android.core.identity.TwitterAuthClient

# Don't note a bunch of dynamically referenced classes
-dontnote com.google.**
-dontnote com.facebook.**
-dontnote com.twitter.**
-dontnote com.squareup.okhttp.**
-dontnote okhttp3.internal.**

Expand Down
2 changes: 0 additions & 2 deletions auth/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@ dependencies {
compileOnly(Config.Libs.Provider.facebook)
implementation(Config.Libs.Support.v4) // Needed to override deps
implementation(Config.Libs.Support.cardView) // Needed to override Facebook
compileOnly(Config.Libs.Provider.twitter) { isTransitive = true }

testImplementation(Config.Libs.Test.junit)
testImplementation(Config.Libs.Test.truth)
testImplementation(Config.Libs.Test.mockito)
testImplementation(Config.Libs.Test.robolectric)
testImplementation(Config.Libs.Provider.facebook)
testImplementation(Config.Libs.Provider.twitter) { isTransitive = true }

debugImplementation(project(":internal:lintchecks"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,6 @@ public AuthMethodPickerLayout.Builder setFacebookButtonId(@IdRes int facebookBtn
return this;
}

/**
* Set the ID of the Twitter sign in button in the custom layout.
*/
public AuthMethodPickerLayout.Builder setTwitterButtonId(@IdRes int twitterBtn) {
providersMapping.put(TwitterAuthProvider.PROVIDER_ID, twitterBtn);
return this;
}

/**
* Set the ID of the Email sign in button in the custom layout.
*/
Expand Down
33 changes: 0 additions & 33 deletions auth/src/main/java/com/firebase/ui/auth/AuthUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

import com.facebook.login.LoginManager;
import com.firebase.ui.auth.data.model.FlowParameters;
import com.firebase.ui.auth.data.remote.TwitterSignInHandler;
import com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity;
import com.firebase.ui.auth.util.CredentialUtils;
import com.firebase.ui.auth.util.ExtraConstants;
Expand Down Expand Up @@ -66,9 +65,7 @@
import com.google.firebase.auth.GithubAuthProvider;
import com.google.firebase.auth.GoogleAuthProvider;
import com.google.firebase.auth.PhoneAuthProvider;
import com.google.firebase.auth.TwitterAuthProvider;
import com.google.firebase.auth.UserInfo;
import com.twitter.sdk.android.core.TwitterCore;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down Expand Up @@ -116,7 +113,6 @@ public final class AuthUI {
Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
GoogleAuthProvider.PROVIDER_ID,
FacebookAuthProvider.PROVIDER_ID,
TwitterAuthProvider.PROVIDER_ID,
GithubAuthProvider.PROVIDER_ID,
EmailAuthProvider.PROVIDER_ID,
PhoneAuthProvider.PROVIDER_ID,
Expand All @@ -132,7 +128,6 @@ public final class AuthUI {
Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
GoogleAuthProvider.PROVIDER_ID,
FacebookAuthProvider.PROVIDER_ID,
TwitterAuthProvider.PROVIDER_ID,
GithubAuthProvider.PROVIDER_ID)));

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
Expand Down Expand Up @@ -437,10 +432,6 @@ private Task<Void> signOutIdps(@NonNull Context context) {
if (ProviderAvailability.IS_FACEBOOK_AVAILABLE) {
LoginManager.getInstance().logOut();
}
if (ProviderAvailability.IS_TWITTER_AVAILABLE) {
TwitterSignInHandler.initializeTwitter();
TwitterCore.getInstance().getSessionManager().clearActiveSession();
}
return GoogleSignIn.getClient(context, GoogleSignInOptions.DEFAULT_SIGN_IN).signOut();
}

Expand All @@ -456,7 +447,6 @@ public SignInIntentBuilder createSignInIntentBuilder() {
@StringDef({
GoogleAuthProvider.PROVIDER_ID,
FacebookAuthProvider.PROVIDER_ID,
TwitterAuthProvider.PROVIDER_ID,
GithubAuthProvider.PROVIDER_ID,
EmailAuthProvider.PROVIDER_ID,
PhoneAuthProvider.PROVIDER_ID,
Expand Down Expand Up @@ -1049,29 +1039,6 @@ public FacebookBuilder setPermissions(@NonNull List<String> permissions) {
}
}

/**
* {@link IdpConfig} builder for the Twitter provider.
*/
public static final class TwitterBuilder extends Builder {
public TwitterBuilder() {
super(TwitterAuthProvider.PROVIDER_ID);
if (!ProviderAvailability.IS_TWITTER_AVAILABLE) {
throw new RuntimeException(
"Twitter provider cannot be configured " +
"without dependency. Did you forget to add " +
"'com.twitter.sdk.android:twitter-core:VERSION' dependency?");
}
Preconditions.checkConfigured(getApplicationContext(),
"Twitter provider unconfigured. Make sure to add your key and secret." +
" See the docs for more info:" +
" https://github" +
".com/firebase/FirebaseUI-Android/blob/master/auth/README" +
".md#twitter",
R.string.twitter_consumer_key,
R.string.twitter_consumer_secret);
}
}

/**
* {@link IdpConfig} builder for the GitHub provider.
*/
Expand Down
Loading