Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.messners.gitlab.api;
 
 import  com.sun.jersey.api.representation.Form;


This class implements the client side API for the GitLab login call.

Author(s):
Greg Messner <greg@messners.com>
public class SessionApi extends AbstractApi {
	public SessionApi (GitLabApi gitLabApi) {
		super(gitLabApi);
	}


Login to get private token. POST /session

Parameters:
username
email
password
Returns:
a Session instance with info on the logged in user
Throws:
GitLabApiException
	public Session login (String usernameString emailString passwordthrows GitLabApiException {
		if ((username == null || username.trim().length() == 0) 
				&& (email == null || email.trim().length() == 0)) {
			throw new IllegalArgumentException("both username and email cannot be empty or null");
		}
		Form formData = new Form();
		addFormParam(formData"email"emailfalse);
		addFormParam(formData"password"passwordtrue);
		addFormParam(formData"login"usernamefalse);		
		ClientResponse response = post(..formData"session");
		return (response.getEntity(Session.class));
	}
New to GrepCode? Check out our FAQ X