Flipkart卖家API访问令牌生成问题

时间:2016-08-01 08:36:45

标签: api oauth-2.0 flipkart-api

我正在尝试访问flip-kart卖家API,因为我在Flipkart卖家API - 开发人员管理门户网站上注册了以下步骤: -

https://seller.flipkart.com/api-docs/FMSAPI.html

成功注册Flipkart后,我点击了用于生成访问令牌的第一个API,但是当我通过我的代码点击此API时,它将返回登录页面html作为响应。我还尝试通过以下步骤通过邮递员点击这个: -

1)Type of request i tried with both (GET,POST)
2)Set appid and app-secret in the header 
3)Use the following url:-
https://api.flipkart.net/oauth-service/oauth/token\?grant_type\=client_credentials\&scope=Seller_Api

我得到以下回复: -

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>Flipkart</title>
        <link type="text/css" rel="stylesheet"
    href="./style.css" />
        <link type="text/css" rel="stylesheet"
        href="./bootstrap.css" />
    </head>
    <body>
        <div class="navbar navbar-default navbar-static-top" role="navigation">
            <div class="container">
                <div class="navbar-header">
                    <a class="navbar-brand" href="#">Flipkart Permission Registration</a>
                </div>
            </div>
        </div>
        <div class="container">
            <form id="loginForm" name="loginForm" role="form" class="form-signin" action="login.do" method="post">
                <h2 class="form-signin-heading">Please sign in </h2>
                <input type="email" class="form-control" placeholder="Email address"
            name='j_username' required="" autofocus="">
                <input type="password"  name='j_password' class="form-control"
            placeholder="Password" required="">
                <button class="btn btn-lg btn-primary btn-block" type="submit" name="login">Sign in</button>
                <input type="hidden" name="CSRFToken" value="987f582b-9a4e-4c6c-a14b-681f2b57ca34"></input>
            </form>
        </div>
    </body>
</html>

我也尝试过他们提供的沙箱网址,但两种情况都有相同的响应。

当我谷歌这个问题时,我发现你需要更改网址,如: -

https://api.flipkart.net/oauth-service/oauth/token?grant_type=client_credentials&scope=Seller_Api

我也试过这个,但这会将响应返回为: -

{
  "error": "unauthorized",
  "error_description": "An Authentication object was not found in the SecurityContext"
}

所以最后我无法获得flipkart卖家API的访问令牌。请帮我 任何帮助,将不胜感激 谢谢!

1 个答案:

答案 0 :(得分:0)

您可以在浏览器中使用以下网址获取authCode,方法是将appId替换为您的flipkart appId:https://api.flipkart.net/oauth-service/oauth/authorize?client_id=appId&grant_type=authorization_code&response_type=code&scope=Seller_Api&state=1234

获得authCode后,使用curl命令,您可以通过提供appId,appSecretKey和authCode来获取访问令牌:curl -u appId:appSecretKey https://api.flipkart.net/oauth-service/oauth/token \?grant_type = authorization_code \&amp; state = 1234 \&amp; ;代码= AUTHCODE