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