如何解决woocommerce_rest_cannot_view 与 oauth 1.0
我使用 OAuth 1.0a 以管理员身份验证我的 android 应用程序以查看 Woocommercerest API 源 我使用了改造库,它可以工作,但今天我遇到了这个问题
I/okhttp.OkHttpClient: Content-Type: application/json;字符集=UTF-8 {"code":"woocommerce_rest_cannot_view","message":"抱歉,您无法列出资源。","data":{"status":401}}
我用 localhost 和我的真实站点尝试过,但仍然是同样的问题 我尝试使用 HTTP 和 HTTPS 并将 useClearTextTrafix 添加到 true 中,但仍然存在相同的问题 我尝试通过 HTTP 和 HTTPS 使用 Woocommerce rest API 身份验证 还是一样的问题
我的 apiClient
if (retrofit == null) {
OAuthInterceptor oauth1WooCommerce = new OAuthInterceptor.Builder()
.consumerKey(CONSUMER_KEY)
.consumerSecret(CONSUMER_SECRET)
.token(TOKEN)
.tokenSecret(TOKEN_SECRET)
.isShouldExcludeOAuthToken(false)
.build();
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder builder = new OkHttpClient().newBuilder().connectTimeout(3,TimeUnit.MINUTES).readTimeout(3,TimeUnit.MINUTES);
builder.addInterceptor(interceptor);
if (isShouldAddOauth1) {
builder.addInterceptor(oauth1WooCommerce);
}
retrofit = new Retrofit.Builder()
.baseUrl(Constants.BASE_URL)
.client(builder.build())
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retrofit.create(ApiInterface.class);
我在 StackOverflow 中看到了所有问题,但没有找到答案 它适用于邮递员,但有时我会收到此错误
{
"code": "json_oauth1_signature_mismatch","message": "OAuth signature does not match","data": {
"status": 401
}
}
请帮忙,谢谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。