【问题标题】:How to access WSO2 API Manager's Store API?如何访问 WSO2 API Manager 的 Store API?
【发布时间】:2016-04-14 23:56:06
【问题描述】:

我正在阅读他们的Store API 的 WSO2 APIM 文档。但是我不知道如何使用这个 API 进行身份验证。

据我了解,我需要通过 /token API 获取特殊令牌。但是这个例子表明他们提供了某种身份验证来获取这个令牌,我不知道它是哪一个。

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

【问题讨论】:

    标签: wso2 wso2-am


    【解决方案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
    }
    

    这里它使用基本身份验证。您需要在授权标头中提供 base 64 编码的用户名:密码(例如:admin:admin)。

    示例响应。

    {
        "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.使用token API获取oauth访问token

    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

    【讨论】:

    • 这是文档中缺少的信息(散列什么以及如何散列)。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多