private void step1GetOAuthToken() {

    mStatus1.setDisplayedChild(1);
    mStatus2.setDisplayedChild(0);
    mStatus3.setDisplayedChild(0);

    mButtonContainer.setDisplayedChild(1);

    new Handler()
        .postDelayed(
            new Runnable() {
              @Override
              public void run() {

                LinkedIdWizard wizard = (LinkedIdWizard) getActivity();
                if (wizard == null) {
                  return;
                }
                wizard.oAuthRequest(
                    "github.com/login/oauth/authorize", "7a011b66275f244d3f21", "gist");
              }
            },
            250);
  }
  private void step3EditKey(final GithubResource resource) {

    mStatus3.setDisplayedChild(1);

    new Handler()
        .postDelayed(
            new Runnable() {
              @Override
              public void run() {

                WrappedUserAttribute ua = LinkedAttribute.fromResource(resource).toUserAttribute();
                mSaveKeyringParcel = new SaveKeyringParcel(mMasterKeyId, mFingerprint);
                mSaveKeyringParcel.mAddUserAttribute.add(ua);

                cryptoOperation();
              }
            },
            250);
  }
 @Override
 public void onCryptoOperationCancelled() {
   super.onCryptoOperationCancelled();
   mStatus3.setDisplayedChild(3);
 }
 @Override
 public void onCryptoOperationError(EditKeyResult result) {
   result.createNotify(getActivity()).show(this);
   mStatus3.setDisplayedChild(3);
 }
 @Override
 public void onCryptoOperationSuccess(EditKeyResult result) {
   mStatus3.setDisplayedChild(2);
 }
  private void step2PostGist(final String accessToken, final String gistText) {

    mStatus2.setDisplayedChild(1);

    new AsyncTask<Void, Void, JSONObject>() {
      @Override
      protected JSONObject doInBackground(Void... dummy) {
        try {

          long timer = System.currentTimeMillis();

          JSONObject file = new JSONObject();
          file.put("content", gistText);

          JSONObject files = new JSONObject();
          files.put("file1.txt", file);

          JSONObject params = new JSONObject();
          params.put("public", true);
          params.put("description", "OpenKeychain API Tests");
          params.put("files", files);

          JSONObject result = jsonHttpRequest("https://api.github.com/gists", params, accessToken);

          // ux flow: this operation should take at last a second
          timer = System.currentTimeMillis() - timer;
          if (timer < 1000)
            try {
              Thread.sleep(1000 - timer);
            } catch (InterruptedException e) {
              // never mind
            }

          return result;

        } catch (IOException e) {
          Log.e(Constants.TAG, "error in request", e);
        } catch (JSONException e) {
          throw new AssertionError("json error, this is a bug!");
        }
        return null;
      }

      @Override
      protected void onPostExecute(JSONObject result) {
        super.onPostExecute(result);

        Log.d(Constants.TAG, "response: " + result);

        if (result == null) {
          mStatus2.setDisplayedChild(3);
          return;
        }

        try {
          String gistId = result.getString("id");
          JSONObject owner = result.getJSONObject("owner");
          String gistLogin = owner.getString("login");

          URI uri = URI.create("https://gist.github.com/" + gistLogin + "/" + gistId);
          GithubResource resource = GithubResource.create(uri);

          mStatus2.setDisplayedChild(2);
          step3EditKey(resource);

        } catch (JSONException e) {
          mStatus2.setDisplayedChild(3);
          e.printStackTrace();
        }
      }
    }.execute();
  }