{"errors":"[API] Invalid API key or access token (unrecognized login or wrong password)"}

Paul_Hargrave
Tourist
16 0 3

I am trying to get response in android for this /admin/products.json api . Using this code.
            OkHttpClient client12 = new OkHttpClient();
            Request request = new Request.Builder()
                    .url("https://-------------/admin/products.json")
                    .get()
//                    .addHeader("Authorization", "b41f1a2a-8aff-79a7-eded-844b14b4791c")
                    .build();
     
                Response response = client12.newCall(request).execute();

but getting error response.  {"errors":"[API] Invalid API key or access token (unrecognized login or wrong password)"}
can you please help me out from this. what code i need to add ? or How to add create header value? because the same "/admin/products.json" i am able to implement in IOS.

0 Likes
Paul_Hargrave
Tourist
16 0 3

I Got the solution by adding header with encode values.
 

String authorizationHeader = "Basic "+"erfrfrfvdfrvdfr4345455=";
// Here this is Base 64 encoding of "SHOPIFY_API_KEY:SHOPIFY_API_PASSWORD"

OkHttpClient client12 = new OkHttpClient();
Request request = newRequest.Builder().url("https://SHOPIFY_API_KEY:SHOPIFY_API_PASSWORD@dsdcdc.com/admin/products.json")
        .get()
.addHeader("Authorization",authorizationHeader).build();
Response response = client12.newCall(request).execute();
rajgauravworld
New Member
1 0 0

Added Basic Auth header from my Java Code and It worked from me. 

Earlier, there was error like "[API] Invalid API key or access token (unrecognized login or wrong password)"

Thanks a lot!

0 Likes