Skip to content
Advertisement

Get access token to Flipkart seller account using php

Can anyone help to get access token by using Flipkart app id and app secret.

We have tried with the code below:

<?php
$username='appid';
$password='appsecret';
$url='https://api.flipkart.net/oauth-service/oauth/token?grant_type=client_credentials&scope=Seller_Api';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
$output = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);   //get status code
$info = curl_getinfo($ch);
curl_close($ch);

if(curl_errno($ch)){   
    echo 'Curl error: ' . curl_error($ch);
}
print_r($output);
echo $status_code;

But we get the error:

{“error”:”invalid_grant”,”error_description”:”Unauthorized grant type: client_credentials”} 400

Advertisement

Answer

I ran through the same issue and after struggling for a couple of hours I went to my seller account and recreated my “Application Id” and “Application Secret”. The only difference I made was I selected “self_access_application” instead of “third_party_application” this time and I was good to go. Please refer: https://nimb.ws/sziWmA

Hope this helps Thanks

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement