我无法在 stripe.com 中进行身份验证 - 使用基本身份验证
public class Str extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter pw=response.getWriter();
pw.println("Hello World");
HttpClient client= new HttpClient();
String req="https://api.stripe.com/";
client.getParams().setAuthenticationPreemptive(true);
client.getState().setCredentials(new AuthScope(req, 443, null), new UsernamePasswordCredentials("<api-key>"));
client.getHostConfiguration().setHost(req, 443, "https");
PostMethod post= new PostMethod("https://api.stripe.com/v1/charges/");
//post.addParameter("id", "<id>");
int status=client.executeMethod(post);
pw.println(status);
}
}
我正在展示我的代码...在那里我使用 HTTP Basic Auth 向 stripe.com 提供用户凭据