我正在使用LinkedIn REST API获取用户的linkedIn详细信息,它一直工作到今天(过去1个月)。我正在获取基本的详细信息,如名称电子邮件。即使它工作到今天的一半,突然间它正在投掷这个错误,
Caused by: com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceException: oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: https://api.linkedin.com/uas/oauth/requestToken
at com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceImpl.getOAuthRequestToken(LinkedInOAuthServiceImpl.java:180)
at in.techchefs.talktemple.login.LinkedInAsyncTask.doInBackground(LinkedInAsyncTask.java:45)
at in.techchefs.talktemple.login.LinkedInAsyncTask.doInBackground(LinkedInAsyncTask.java:14)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: https://api.linkedin.com/uas/oauth/requestToken
at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:214)
at oauth.signpost.AbstractOAuthProvider.retrieveRequestToken(AbstractOAuthProvider.java:69)
at com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceImpl.getOAuthRequestToken(LinkedInOAuthServiceImpl.java:172)
at in.techchefs.talktemple.login.LinkedInAsyncTask.doInBackground(LinkedInAsyncTask.java:45)
at in.techchefs.talktemple.login.LinkedInAsyncTask.doInBackground(LinkedInAsyncTask.java:14)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.io.FileNotFoundException: https://api.linkedin.com/uas/oauth/requestToken
这是代码,
public class LinkedInAsyncTask extends AsyncTask<String, Void, Void> {
LinkedInActivity mContext;
public static LinkedInApiClientFactory factory;
public static LinkedInOAuthService oAuthService;
public static LinkedInRequestToken liToken;
public static final String LINKEDIN_CONSUMER_KEY = "XXXXXXX";//gave like this for security purpose only.
public static final String LINKEDIN_CONSUMER_SECRET = "XXXXXXX";
public static final String OAUTH_CALLBACK_SCHEME = "x-oauthflow-linkedin";
public static final String OAUTH_CALLBACK_HOST = "callback";
// public static final String OAUTH_CALLBACK_URL = OAUTH_CALLBACK_SCHEME + "://" + OAUTH_CALLBACK_HOST;
public static String OAUTH_CALLBACK_URL = "x-oauthflow-linkedin://callback";
public LinkedInAsyncTask(LinkedInActivity mContext) {
this.mContext = mContext;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected Void doInBackground(String... params) {
LinkedinDialog.oAuthService = LinkedInOAuthServiceFactory.getInstance().createLinkedInOAuthService(LINKEDIN_CONSUMER_KEY, LINKEDIN_CONSUMER_SECRET);
LinkedinDialog.factory = LinkedInApiClientFactory.newInstance(LINKEDIN_CONSUMER_KEY, LINKEDIN_CONSUMER_SECRET);
LinkedinDialog.liToken = LinkedinDialog.oAuthService.getOAuthRequestToken(OAUTH_CALLBACK_URL);
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
mContext.setWebView();
}
}
请建议。
答案 0 :(得分:0)
我找到了解决方案!,问题是因为我是在模拟器上运行(长时间打开)来自模拟器的时间数据与linkedIn服务器不匹配,即使有很小的时间差也拒绝请求。因此,唯一的解决方案是关闭并重新启动模拟器。希望,这可以帮助某人。