code: public String build(Protocol protocol, String oauthToken, String oauthTokenSecret)
        throws IOException, OAuthException, URISyntaxException {
      OAuthAccessor accessor = new OAuthAccessor(consumer);
      accessor.tokenSecret = oauthTokenSecret;
  
      Map<String, String> parameters = new HashMap<String, String>();
      parameters.put(OAuth.OAUTH_SIGNATURE_METHOD, "HMAC-SHA1");
      parameters.put(OAuth.OAUTH_TOKEN, oauthToken);
  
      String url = String.format("https://mail.google.com/mail/b/%s/%s/", email,
          (Protocol.IMAP == protocol) ? "imap" : "smtp");
  
      OAuthMessage message = new OAuthMessage(
          "GET",
          url,
          parameters.entrySet());
      message.addRequiredParameters(accessor);
  
      StringBuilder authString = new StringBuilder();
      authString.append("GET ");
      authString.append(url);
      authString.append(" ");
      int i = 0;
      for (Map.Entry<String, String> entry : message.getParameters()) {
        if (i++ > 0) {
          authString.append(",");
        }
        authString.append(OAuth.percentEncode(entry.getKey()));
        authString.append("=\"");
        authString.append(OAuth.percentEncode(entry.getValue()));
        authString.append("\"");
      }
  
      return Base64.encode(authString.toString().getBytes());
    }
docs: Builds an XOAUTH SASL client response.
  
  @return A base-64 encoded containing the auth string suitable for login via xoauth.