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 (将#修改为@)