2016-04-14 118 views
1

我正在阅读他们的Store API的WSO2 APIM文档。但是我无法弄清楚如何使用此API进行身份验证。如何访问WSO2 API Manager的Store API?

从我所了解的这个页面,我需要通过/ token API获取一个特殊的标记。但是这个例子表明他们提供了某种认证来获得这个令牌,我不知道它是哪一个。

所以我想我的问题是: - 如何获取WSO API Manager的新Store API的访问令牌?

回答

1

以下是如何获取(Reference)。

1.注册使用动态客户端注册API您的OAuth应用

curl -X POST -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Content-Type: application/json" -d @payload.json http://localhost:9763/client-registration/v0.9/register 

样品有效载荷:

{ 
    "callbackUrl": "www.google.lk", 
    "clientName": "rest_api_store", 
    "tokenScope": "Production", 
    "owner": "admin", 
    "grantType": "password refresh_token", 
    "saasApp": true 
} 

这采用基本auth.You需要提供基64编码的用户名:密码(例如:admin:admin)在Authrization标题中。

样本响应。

{ 
    "callBackURL": "www.google.lk", 
    "jsonString": 
    "{ 
    "username":"admin", 
    "redirect_uris":"www.google.lk", 
    "tokenScope":[Ljava.lang.String;@3a73796a, 
    "client_name":"admin_rest_api_store", 
    "grant_types":"authorization_code password refresh_token iwa:ntlm 
    urn:ietf:params:oauth:grant-type:saml2-bearer client_credentialsimplicit" 
    }", 
    "clientName": null, 
    "clientId": "HfEl1jJPdg5tbtrxhAwybN05QGoa", 
    "clientSecret": "l6c0aoLcWR3fwezHhc7XoGOht5Aa" 
} 

2.使用令牌API来获取OAuth访问令牌

curl -k -d "grant_type=password&username=admin&password=admin&scope=apim:subscribe" -H "Authorization: Basic SGZFbDFqSlBkZzV0YnRyeGhBd3liTjA1UUdvYTpsNmMwYW9MY1dSM2Z3ZXpIaGM3WG9HT2h0NUFh" https://127.0.0.1:8243/toke 

这里基本身份验证参数是base 64编码的clientId:ClientSecret

现在你有一个访问令牌调用存储API

+0

这是在文档中丢失的信息(如何散列以及如何散列它)。谢谢! –