我创建了一个从upwork.com获取信息的应用。我使用java lib和Upwork OAuth 1.0。问题是本地请求API运行良好,但当我部署到Google Cloud时,我的代码无法工作。我得到({"error":{"code":"503","message":"Exception: IOException"}})。
我为return OAuthClient创建了UpworkAuthClient,接下来它用于JobClient中的请求。
run() {
UpworkAuthClient upworkClient = new UpworkAuthClient();
upworkClient.setTokenWithSecret("USER TOKEN", "USER SECRET");
OAuthClient client = upworkClient.getOAuthClient();
//set query
JobQuery jobQuery = new JobQuery();
jobQuery.setQuery("query");
List<JobQuery> jobQueries = new ArrayList<>();
jobQueries.add(jobQuery);
// Get request of job
JobClient jobClient = new JobClient(client, jobQuery);
List<Job> result = jobClient.getJob();
}
public class UpworkAuthClient {
public static final String CONSUMERKEY = "UPWORK KEY";
public static final String CONSUMERSECRET = "UPWORK SECRET";
public static final String OAYTРCALLBACK = "https://my-app.com/main";
OAuthClient client ;
public UpworkAuthClient() {
Properties keys = new Properties();
keys.setProperty("consumerKey", CONSUMERKEY);
keys.setProperty("consumerSecret", CONSUMERSECRET);
Config config = new Config(keys);
client = new OAuthClient(config);
}
public void setTokenWithSecret (String token, String secret){
client.setTokenWithSecret(token, secret);
}
public OAuthClient getOAuthClient() {
return client;
}
public String getAuthorizationUrl() {
return this.client.getAuthorizationUrl(OAYTРCALLBACK);
}
}
public class JobClient {
private JobQuery jobQuery;
private Search jobs;
public JobClient(OAuthClient oAuthClient, JobQuery jobQuery) {
jobs = new Search(oAuthClient);
this.jobQuery = jobQuery;
}
public List<Job> getJob() throws JSONException {
JSONObject job = jobs.find(jobQuery.getQueryParam());
jobList = parseResponse(job);
return jobList;
}
}本地开发服务器工作得很好,我在本地机器上得到了重新填塞,但在云中却不是。我会很高兴有任何想法,谢谢!
发布于 2019-02-27 00:00:11
{"error":{"code":"503","message":"Exception: IOException"}}看起来不像是Upwork API返回的响应。您能否提供完整的响应,包括返回的报头?因此,我们将对其进行更精确的研究。
https://stackoverflow.com/questions/54707816
复制相似问题