Saturday, 15 June 2013

java - Attempt to get OAuth access token from Neteller produces error: "Server returned HTTP response code: 401 for URL" -


I want to set up a successful request for Neteller, I am trying to get the token using the code from the Neteller documentation I

However, it fails consistently with the following exceptions:

  java.io.IOException: The server returned the HTTP response code: 401 for the URL: https: // Test.api.neteller.com/v1/Oauth2/token? Grant_type = client_credentials  

Here is the code (again, from the netler document):

  string testUrl = "https: // test .api.neteller.com "; String protected url = "https://api.neteller.com"; String url = testUrl; If ("live" .equals (configBean.get ("environment"))) {url = secureUrl; } Url + = "/ v1 / oauth2 / token? Grant_type = client_credentials"; String xml = "grant_type = client_credentials? Grant_type = client_credentials"; Xml = ""; String Test = Base64.exodabytes ((AccountID + ":" + + Secure ID) .getBytes ()); {URL should try urls = new URL ("https://test.api.neteller.com/v1/oauth2/token?grant_type=client_credentials"); HttpURL Connection Connection = (HttpURLConnection) urls.openConnection (); Connection.setRequestMethod ("post"); Connection.setDoOutput (true); Connection.setRequestProperty ("Authority", "Bearer" + Exam); Connection.setRequestProperty ("content-type", "app / json"); Connection.setRequestProperty ("cache-control", "no-cache"); DataOutputStream wr = New DataOutputStream (connection.getOutputStream ()); Wr.flush (); Wr.close (); BufferedReader = new in BufferedReader (new InputStreamReader (connection.getInputStream ())); String inputline; String buffer response = new stringbuffer (); While ((inputLine = in.readline ()) = null) {response.append (inputLine); } In.close (); String AccessToken = ""; } Hold (exception e) {e.printStackTrace (); }  

Why is my implementation unsuccessful here? There is nothing wrong in your code. The problem is that you have a for API integration.

, where you need to use the merchant account for that to work below you will need to complete these steps:

  1. You will need to get a test merchant account (). Registration at www.wweller.com creates a regular member account, which can not receive payment through the API
  2. Once you have a test merchant account, you will be given a white list of that IP address Will be required to provide the API that you are requesting. (Page 31 of the manual).
  3. After that, you have to add an app for it (page 32 of the manual).
  4. Once you add an application, use "Client ID" and "Client Secret" in the authorization header - as you do now, base64 encoded values ​​are different from colon (:) .

No comments:

Post a Comment