在WSO2 API Manager中生成使用者密钥和使用者密钥

时间:2014-07-02 17:13:14

标签: wso2 wso2-am

我想将WSO2 API Manager与网站集成,以便用户无需登录API Store。

从我所看到的是一个绊脚石,因为用户需要点击“生成”#39;商店中的按钮,以便首先生成消费者密钥和秘密。

完成此操作后,就可以调用订阅API并生成令牌API,如下所示:

$ curl -b cookies http://localhost:9763/store/site/blocks/subscription/subscription-list/ajax/subscription-list.jag?action=getAllSubscriptions
{
   "error" : false,
   "subscriptions" : [
      {
      {
         "sandRegenarateOption" : true,
         "prodKey" : "2486e65cbac4e372fb319375744fb",
         "subscriptions" : [
            {
               ...
               "prodConsumerSecret" : "Tx9i9WYu6_a3qqW08bF7jEG660",
               "prodConsumerKey" : "VfS5r5u4rFhec2vVBlFosxRgcE",
               "prodAuthorizedDomains" : "ALL"
               ...
            }
         ],
         ...
         "prodConsumerSecret" : "Tx9i9WYu6_a3qqW08bF7jEG660",
         "prodConsumerKey" : "VfS5r5u4rFhec2vVBlFosxRgcE"
         ...
      }
   ]
}

然而,直到'生成'在浏览器中单击了按钮,上面的值为null

当我尝试使用该建议时:

$ curl -X POST -b cookies http://localhost:9763/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag -d "action=generateApplicationKey&application=4&keytype=PRODUCTION&provider=admin&tier=Unlimited&version=0.1&callbackUrl=&authorizedDomains="

服务器记录:

ERROR - APIStoreHostObject Error while obtaining the application access token for the application:4
org.wso2.carbon.apimgt.api.APIManagementException: Application should be approved before registering.
    at org.wso2.carbon.apimgt.impl.APIConsumerImpl.requestApprovalForApplicationRegistration(APIConsumerImpl.java:1678)
    at org.wso2.carbon.apimgt.impl.UserAwareAPIConsumer.requestApprovalForApplicationRegistration(UserAwareAPIConsumer.java:34)
    at org.wso2.carbon.apimgt.hostobjects.APIStoreHostObject.jsFunction_getApplicationKey(APIStoreHostObject.java:649)

但是根据getApplications API,它已被批准:

curl -b cookies   http://localhost:9763/store/site/blocks/application/application-list/ajax/application-list.jag?action=getApplications
{
   "applications" : [
      ...
      {
         "tier" : "Unlimited",
         "status" : "APPROVED",
         "callbackUrl" : "",
         "name" : "app2",
         "id" : 4,
         "description" : ""
      }
   ],
   "error" : false
}

还有什么想法吗?

3 个答案:

答案 0 :(得分:0)

我没有看到任何直接的方法来完成这项工作。但是你可以使用wso2 API manger公开的Store API并检索所有订阅,然后你可以过滤所需的ConsumerKey和ConsumerSecret。

我已经尝试了这个并且对我很好地工作:)

答案 1 :(得分:0)

您可以尝试以下REST调用

curl -X POST -b cookies http://localhost:9763/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag -d "action=generateApplicationKey&application=DefaultApplication&keytype=PRODUCTION&provider=admin&tier=Unlimited&version=1.0.0&callbackUrl=&authorizedDomains="

答案 2 :(得分:0)

您需要在订阅前进行宣传。您需要使用“PUBLISHED”状态和“updateStatus”操作调用“/site/blocks/life-cycles/ajax/life-cycles.jag”端点。一旦它处于提升状态,您就可以订阅它。