我创建了用于从upwork.com获取信息的应用。我使用Java库和Upwork OAuth 1.0。问题是对API的本地请求工作正常,但是当我将其部署到Google Cloud时,我的代码无法正常工作。我得到了({“ error”:{“ code”:“ 503”,“ message”:“ Exception:IOException”}}})。
我创建UpworkAuthClient以返回OAuthClient,然后将其用于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;
}
}
本地开发服务器工作正常,我在本地计算机上获得更新,但在Cloud中却无法。 我会对任何想法感到高兴,谢谢!
答案 0 :(得分:0)
{"error":{"code":"503","message":"Exception: IOException"}}
似乎不是Upwork API的响应返回。您能否提供完整的回复,包括返回的标题?因此,我们将对其进行更精确的研究。