2016-04-14 122 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

這是在文檔中丟失的信息(如何散列以及如何散列它)。謝謝! –

相關問題