我在Android上得到使用檢索ucoz.api.ru(OAuth的1.0A)時,這些錯誤令牌scribe library oauth(4.2.0):機器人,OAuth的1.0A,隸=例外
產生的原因:com.github.scribejava .core.exceptions.OAuthException: 響應正文不正確。不能提取令牌和祕密從這個:
'{ 「的oauth_token」: 「NAzoveaGm5XIlBvLcLRxUvamEK8P2.BAlQZ.M.aV」, 「oauth_token_secret」: 「SJsqC0IfFAKS3BkdauQ3bY4ha01PDHTlFIy7GSro」, 「oauth_callback_confirmed」: 「真正的」}'
在 com.github.scribejava.core.extractors.AbstractOAuth1TokenExtractor.extract(AbstractOAuth1TokenExtractor.java:42) 在 com.github.scribejava.core.extractors.AbstractOAuth1TokenExtractor.extract(AbstractOAuth1TokenExtractor.java:32) 在 COM .github.scribejava.core.extractors.AbstractOAuth1TokenExtractor.extract(AbstractOAuth1TokenExtractor.java:19) 在 com.github.scribejava.core.oauth.OAuth10aService.getRequestToken(OAuth10aService.java:49) 在 com.vasyaevstropov.oauth10test.MainActivity.request(MainActivity.java:96) 在 com.vasyaevstropov.oauth10test (MainActivity.java:53) at android.os.AsyncTask $ 2.call(AsyncTask.java:288).MainActivity $ 1 $ 1.doInBackground ) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask $ SerialExecutor $ 1.run(Asyn cTask.java:231) 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 在 java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:587) 是java。 lang.Thread.run(Thread.java:841)
我的源代碼:
final OAuth10aService service = new ServiceBuilder(CONSUMER_KEY)
.apiSecret(CONSUMER_SECRET)
.debug()
.build(UcozApi.instance());
final Scanner in = new Scanner(System.in);
// Obtain the Request Token
final OAuth1RequestToken requestToken = service.getRequestToken(); // <<--- Error is in this place
System.out.println(service.getAuthorizationUrl(requestToken));
final String oauthVerifier = in.nextLine();
// Trade the Request Token and Verfier for the Access Token
OAuth1AccessToken accessToken = null;
try {
accessToken = service.getAccessToken(requestToken, oauthVerifier);
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
Ucozapi模塊:
public class UcozApi extends com.github.scribejava.core.builder.api.DefaultApi10a {
private static final String AUTHORIZE_URL = "http://uapi.ucoz.com/accounts/oauthauthorizetoken=%s";
private static final String REQUEST_TOKEN_RESOURCE = "http://uapi.ucoz.com/accounts/oauthgetrequesttoken";
private static final String ACCESS_TOKEN_RESOURCE = "http://uapi.ucoz.com/accounts/oauthgetaccesstoken";
protected UcozApi() {
}
private static final UcozApi INSTANCE = new UcozApi();
public static UcozApi instance() {
return INSTANCE;
}
@Override
public String getAccessTokenEndpoint() {
return ACCESS_TOKEN_RESOURCE;
}
@Override
public String getRequestTokenEndpoint() {
return REQUEST_TOKEN_RESOURCE;
}
@Override
public String getAuthorizationUrl(OAuth1RequestToken requestToken) {
return String.format(AUTHORIZE_URL, requestToken.getToken());
}
}
有人可以幫我嗎?