use of com.twitter.sdk.android.core.TwitterAuthConfig in project FirebaseAuth-Android by jirawatee.
the class TwitterLoginActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Configure Twitter SDK
TwitterAuthConfig authConfig = new TwitterAuthConfig(getString(R.string.twitter_consumer_key), getString(R.string.twitter_consumer_secret));
Fabric.with(this, new Twitter(authConfig));
// Inflate layout (must be done after Twitter is configured)
setContentView(R.layout.activity_twitter);
mImageView = findViewById(R.id.logo);
mTextViewProfile = findViewById(R.id.profile);
findViewById(R.id.button_twitter_signout).setOnClickListener(this);
mAuth = FirebaseAuth.getInstance();
mAuthListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
} else {
Log.d(TAG, "onAuthStateChanged:signed_out");
}
updateUI(user);
}
};
// initialize_twitter_login
mLoginButton = findViewById(R.id.button_twitter_login);
mLoginButton.setCallback(new Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> result) {
Log.d(TAG, "twitterLogin:success" + result);
handleTwitterSession(result.data);
}
@Override
public void failure(TwitterException exception) {
Log.w(TAG, "twitterLogin:failure", exception);
updateUI(null);
}
});
}
use of com.twitter.sdk.android.core.TwitterAuthConfig in project SpaceLaunchNow-Android by ItsCalebJones.
the class LaunchApplication method setupTwitter.
private void setupTwitter() {
TwitterConfig config = new TwitterConfig.Builder(this).logger(new DefaultLogger(Log.DEBUG)).twitterAuthConfig(new TwitterAuthConfig(getString(R.string.consumer_key), getString(R.string.consumer_secret))).debug(true).build();
Twitter.initialize(config);
new Thread(TweetUi::getInstance).start();
}
use of com.twitter.sdk.android.core.TwitterAuthConfig in project commons-android by mtransitapps.
the class OAuth1aService method requestTempToken.
/**
* Requests a temp token to start the Twitter sign-in flow.
*
* @param callback The callback interface to invoke when the request completes.
*/
public void requestTempToken(final Callback<OAuthResponse> callback) {
final TwitterAuthConfig config = getTwitterCore().getAuthConfig();
final String url = getTempTokenUrl();
api.getTempToken(new OAuth1aHeaders().getAuthorizationHeader(config, null, buildCallbackUrl(config), "POST", url, null)).enqueue(getCallbackWrapper(callback));
}
use of com.twitter.sdk.android.core.TwitterAuthConfig in project commons-android by mtransitapps.
the class OAuth2Service method getAuthHeader.
private String getAuthHeader() {
final TwitterAuthConfig authConfig = getTwitterCore().getAuthConfig();
final ByteString string = ByteString.encodeUtf8(UrlUtils.percentEncode(authConfig.getConsumerKey()) + ":" + UrlUtils.percentEncode(authConfig.getConsumerSecret()));
return OAuthConstants.AUTHORIZATION_BASIC + " " + string.base64();
}
use of com.twitter.sdk.android.core.TwitterAuthConfig in project ServiceStack.Java by ServiceStack.
the class LoginActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Twitter(new TwitterAuthConfig(getString(R.string.twitter_key), getString(R.string.twitter_secret))));
setContentView(R.layout.login);
Toolbar toolbar = (Toolbar) findViewById(R.id.loginToolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(true);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
txtStatus = (TextView) findViewById(R.id.txtStatus);
UiHelpers.setStatus(txtStatus, "");
// see this max value coming back here, we animale towards that value
animation = ObjectAnimator.ofInt(progressBar, "progress", 0, 500);
animation.setRepeatMode(ValueAnimator.REVERSE);
animation.setRepeatCount(100);
animation.setDuration(1500);
animation.setInterpolator(new FastOutLinearInInterpolator());
LoginActivity activity = this;
ImageButton btnTwitter = (ImageButton) findViewById(R.id.btnTwitter);
twitterAuth = new TwitterAuthClient();
btnTwitter.setOnClickListener(view -> {
startProgressBar();
twitterAuth.authorize(activity, new Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> result) {
UiHelpers.setStatus(txtStatus, "Local twitter sign-in successful, signing into server...");
TwitterSession session = result.data;
App.get().getServiceClient().postAsync(new dtos.Authenticate().setProvider("twitter").setAccessToken(session.getAuthToken().token).setAccessTokenSecret(session.getAuthToken().secret).setRememberMe(true), r -> {
UiHelpers.setStatus(txtStatus, "Server twitter sign-in successful, opening chat...");
App.get().saveTwitterAccessToken(session.getAuthToken());
Intent intent = new Intent(activity, MainActivity.class);
stopProgressBar();
startActivity(intent);
}, error -> {
UiHelpers.setStatusError(txtStatus, "Server twitter sign-in failed", error);
stopProgressBar();
});
}
@Override
public void failure(TwitterException exception) {
exception.printStackTrace();
stopProgressBar();
}
});
});
facebookCallback = CallbackManager.Factory.create();
LoginManager.getInstance().registerCallback(facebookCallback, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
UiHelpers.setStatus(txtStatus, "Local facebook sign-in successful, signing into server...");
App.get().getServiceClient().postAsync(new dtos.Authenticate().setProvider("facebook").setAccessToken(loginResult.getAccessToken().getToken()).setRememberMe(true), r -> {
UiHelpers.setStatus(txtStatus, "Server facebook sign-in successful, opening chat...");
Intent intent = new Intent(activity, MainActivity.class);
stopProgressBar();
startActivity(intent);
}, error -> {
UiHelpers.setStatusError(txtStatus, "Server facebook sign-in failed", error);
stopProgressBar();
});
}
@Override
public void onCancel() {
stopProgressBar();
}
@Override
public void onError(FacebookException exception) {
Log.e(exception);
stopProgressBar();
}
});
ImageButton btnFacebook = (ImageButton) findViewById(R.id.btnFacebook);
btnFacebook.setOnClickListener(view -> {
startProgressBar();
LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("email"));
});
ImageButton btnAnon = (ImageButton) findViewById(R.id.btnAnon);
btnAnon.setOnClickListener(view -> {
UiHelpers.setStatus(txtStatus, "Opening chat as guest...");
startGuestChatActivity(App.get().getServiceClient());
});
dtos.Authenticate authDto = App.get().getSavedAccessToken();
if (authDto != null) {
UiHelpers.setStatus(txtStatus, "Signing in with saved " + authDto.getProvider() + " AccessToken...");
App.get().getServiceClient().postAsync(authDto, r -> {
Intent intent = new Intent(activity, MainActivity.class);
stopProgressBar();
startActivity(intent);
}, error -> {
UiHelpers.setStatusError(txtStatus, "Error logging into " + authDto.getProvider() + " using Saved AccessToken", error);
stopProgressBar();
});
}
}
Aggregations