title: How to get a paypal access token using REST request
body: <p>I'm trying to get this working <a href="https://developer.paypal.com/webapps/developer/docs/integration/direct/make-your-first-call/" rel="nofollow">https://developer.paypal.com/webapps/developer/docs/integration/direct/make-your-first-call/</a>
  Using Java + Jersey application. It seems like I'm missing something in POST params.</p>
  
  <pre><code>public String getPaypalToken() {
      Client client = Client.create();
      WebResource webResource = client.resource("https://api.sandbox.paypal.com/v1/oauth2/token");
      MultivaluedMap&lt;String, String&gt; queryParams = new MultivaluedMapImpl();
      queryParams.add("username", CLIENT_ID + ":" + SECRET );
      queryParams.add("grant_type", "client_credentials");
      ClientResponse response = webResource.accept("application/json").acceptLanguage("en_US").type("application/x-www-form-urlencoded").post(ClientResponse.class, queryParams);
      return response.toString();
  }
  </code></pre>
  
  <p>Using previous code I got: POST <a href="https://api.sandbox.paypal.com/v1/oauth2/token" rel="nofollow">https://api.sandbox.paypal.com/v1/oauth2/token</a> returned a response status of 401 Unauthorized.</p>
  
  <p>This CURL command line option just works fine:</p>
  
  <pre><code>curl -X POST https://api.sandbox.paypal.com/v1/oauth2/token  -H "Accept: application/json"  -H "Accept-Language: en_US"  -u "EOJ2S-Z6OoN_le_KS1d75wsZ6y0SFdVsY9183IvxFyZp:EClusMEUk8e9ihI7ZdVLF5cZ6y0SFdVsY9183IvxFyZp"  -d "grant_type=client_credentials"
  </code></pre>
  
  <p>Any suggestions will be appreciated.
  J.</p>