title: Twitter Login/Authentication in Android Fragment
body: <p>I am trying to implement a twitter login button in a fragment in Android using Fabric. I got it to work in an activity, but cannot get it working in a fragment.</p>
  
  <p>Here is my TwitterFragment class (extends fragment)</p>
  
  <pre><code>@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
  
  TwitterAuthConfig authConfig = new TwitterAuthConfig(mTWITTER_KEY, mTWITTER_SECRET);
  Fabric.with(super.getActivity(), new Twitter(authConfig));
  
  View view = inflater.inflate(R.layout.twitter_fragment, container, false);
  
  loginButton = (TwitterLoginButton) view.findViewById(R.id.twitter_login_button);
  
  loginButton.setCallback(new Callback&lt;TwitterSession&gt;() {
      @Override
      public void success(Result&lt;TwitterSession&gt; result) {
  
          TwitterSession session = result.data;
  
          String msg = "@" + session.getUserName() + " logged in! (#" + session.getUserId() + ")";
          Toast.makeText(getActivity().getApplicationContext(), msg, Toast.LENGTH_LONG).show();
      }
  
      @Override
      public void failure(TwitterException exception) {
          Log.d("TwitterKit", "Login with Twitter failure", exception);
      }
  });
  
  return view;
  }
  
  
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      //loginButton.onActivityResult(requestCode, resultCode, data);
      Fragment fragment = getFragmentManager().findFragmentById(R.id.twitter_login_button);
      if (fragment != null) {
          fragment.onActivityResult(requestCode, resultCode, data);
      }
  }
  </code></pre>
  
  <p>And my twitter_fragment.xml </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:padding="15dp"&gt;
  
      &lt;com.twitter.sdk.android.core.identity.TwitterLoginButton
          android:id="@+id/twitter_login_button"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerInParent="true"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I am getting this in the first 2 lines of the monitor </p>
  
  <pre><code>Authorization completed with an error
  com.twitter.sdk.android.core.TwitterAuthException: Authorize failed.
  </code></pre>
  
  <p>Any ideas what the issue is?</p>
  
  <p>Thank you,</p>