code: public static String getOtpAuthTotpURL(String issuer,
                                             String accountName,
                                             GoogleAuthenticatorKey credentials)
      {
          URIBuilder uri = new URIBuilder()
                  .setScheme("otpauth")
                  .setHost("totp")
                  .setPath("/" + formatLabel(issuer, accountName))
                  .setParameter("secret", credentials.getKey());
  
          if (issuer != null)
          {
              if (issuer.contains(":"))
              {
                  throw new IllegalArgumentException("Issuer cannot contain the \':\' character.");
              }
  
              uri.setParameter("issuer", issuer);
          }
  
          final GoogleAuthenticatorConfig config = credentials.getConfig();
          uri.setParameter("algorithm", getAlgorithmName(config.getHmacHashFunction()));
          uri.setParameter("digits", String.valueOf(config.getCodeDigits()));
          uri.setParameter("period", String.valueOf((int) (config.getTimeStepSizeInMillis() / 1000)));
  
          return uri.toString();
      }
docs: Returns the basic otpauth TOTP URI. This URI might be sent to the user via email, QR code or some other method.
  Use a secure transport since this URI contains the secret.
  <p/>
  The current implementation supports the following features:
  <ul>
  <li>Label, made up of an optional issuer and an account name.</li>
  <li>Secret parameter.</li>
  <li>Issuer parameter.</li>
  </ul>
  
  @param issuer      The issuer name. This parameter cannot contain the colon
  (:) character. This parameter can be null.
  @param accountName The account name. This parameter shall not be null.
  @param credentials The generated credentials.  This parameter shall not be null.
  @return an otpauth scheme URI for loading into a client application.
  @see <a href="https://github.com/google/google-authenticator/wiki/Key-Uri-Format">Google Authenticator - KeyUriFormat</a>