Reputation: 105
I using OAuth 1.0a to authentication my android app as admin to view Woocommercerest API source I using the retrofit library and it works but today I have this problem
I/okhttp.OkHttpClient: Content-Type: application/json; charset=UTF-8 {"code":"woocommerce_rest_cannot_view","message":"Sorry, you cannot list resources.","data":{"status":401}} <-- END HTTP (107-byte body)
I tried it with localhost and my real site and the still the same problem I tried with HTTP and HTTPS and I added useClearTextTrafix to the true and still the same problem I tried using Woocommerce rest API authentication via HTTP and HTTPS and still the same problem
my 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);
I saw all the questions in StackOverflow and I didn't find my answer it works with postman but sometimes I get this error
{
"code": "json_oauth1_signature_mismatch",
"message": "OAuth signature does not match",
"data": {
"status": 401
}
}
please help, thank you
Upvotes: 1
Views: 753
Reputation: 105
not sure but I think the problem from https://github.com/WP-API/OAuth1 because after I deleted it the problem resolved
And apparently when I tried to authenticate the app using HTTP Woocommerce Rest API There is a conflict between the OAuth1 plugin and Woocommerce Rest API
But My Problem Not Resolved There Is Another OAuth Plugin WordPress to authenticate the app and make it can view all WordPress rest API source ?
thank you
Upvotes: 1