How do you get Access Token using REST?

I'm trying to upload a folder in my Document Library using REST but it requires a Access Token in the header.

Here is the code:

 public void createFolder(String digest) throws ClientProtocolException, IOException {
    HttpPost request = new HttpPost(

    request.addHeader("Content-Type", "application/json;odata=verbose");
    request.addHeader("X-RequestDigest", digest);
    CloseableHttpResponse response = httpClient.execute(target, request, context);
    response.setHeader("Accept", "application/json;odata=verbose");
    System.out.println("STATUS CODE Post Folder: " + response.getStatusLine());


Thanks in advance