code: public static GitLabApi oauth2Login(ApiVersion apiVersion, String url, String username, CharSequence password,
              String secretToken, Map<String, Object> clientConfigProperties, boolean ignoreCertificateErrors) throws GitLabApiException {
  
          if (username == null || username.trim().length() == 0) {
              throw new IllegalArgumentException("both username and email cannot be empty or null");
          }
  
          GitLabApi gitLabApi = new GitLabApi(ApiVersion.OAUTH2_CLIENT, url, (String)null);
          if (ignoreCertificateErrors) {
              gitLabApi.setIgnoreCertificateErrors(true);
          }
  
          class Oauth2Api extends AbstractApi {
              Oauth2Api(GitLabApi gitlabApi) {
                  super(gitlabApi);
              }
          }
  
          try (Oauth2LoginStreamingOutput stream = new Oauth2LoginStreamingOutput(username, password)) {
  
              Response response = new Oauth2Api(gitLabApi).post(Response.Status.OK, stream, MediaType.APPLICATION_JSON, "oauth", "token");
              OauthTokenResponse oauthToken = response.readEntity(OauthTokenResponse.class);
              gitLabApi = new GitLabApi(apiVersion, url, TokenType.OAUTH2_ACCESS, oauthToken.getAccessToken(), secretToken, clientConfigProperties);
              if (ignoreCertificateErrors) {
                  gitLabApi.setIgnoreCertificateErrors(true);
              }
  
              return (gitLabApi);
          }
      }
docs: <p>Logs into GitLab using OAuth2 with the provided {@code username} and {@code password},
  and creates a new {@code GitLabApi} instance using returned access token.</p>
  
  @param url GitLab URL
  @param apiVersion the ApiVersion specifying which version of the API to use
  @param username user name for which private token should be obtained
  @param password password for a given {@code username}
  @param secretToken use this token to validate received payloads
  @param clientConfigProperties Map instance with additional properties for the Jersey client connection
  @param ignoreCertificateErrors if true will set up the Jersey system ignore SSL certificate errors
  @return new {@code GitLabApi} instance configured for a user-specific token
  @throws GitLabApiException GitLabApiException if any exception occurs during execution