Hi guys I'm trying to generate access token for Flipkart Application from Salesforce.

When I run this below command in curl I'm able to get Access Token

curl -u 52a83780666645a39a6b57103657866a9069:29f126a71c7486cb397a2d42317ad8e8d https://sandbox-api.flipkart.net/oauth-service/oauth/token?grant_type=client_credentials&scope=Seller_Api

But same thing generation of access token using http request method I'm trying to do like this.

public class Flipkart_Order {

    public static void Access_Token_demo(){

        String tokenuri = 'https://sandbox-api.flipkart.net/oauth-service/oauth/token?grant_type=client_credentials&scope=Seller_Api';                 
        HttpRequest req = new HttpRequest();

        Blob headerValue = Blob.valueOf('52a83780666645a39a6b57103657866a9069' + ':' + '29f126a71c7486cb397a2d42317ad8e8d');
        String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
        req.setHeader('Authorization', authorizationHeader);

        Http h = new Http();
        String resp;
        HttpResponse res = h.send(req);
        resp = res.getBody();        


After Executing it in Anonymous Window I'm getting this error

System.HttpRequest[Endpoint=https://sandbox-api.flipkart.net/oauth-service/oauth/token?grant_type=client_credentials&scope=Seller_Api, Method=POST]
System.HttpResponse[Status=Unauthorized, StatusCode=401]

Please help me to resolve this.

I raised an issue to Flipkart but they are telling I have to Use https request, I'm wondering how to make an https request..!

  • You service requires certificate to be presented. Try this – Ilya Lepesh Apr 21 '16 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.