2017-05-04 52 views
2

我正在將我的API從舊系統遷移到WSO2 APIM 2.0.0,並試圖使交換機對我的API用戶透明。我已經遷移了現有的consumer_key/secrets。WSO2 APIM 2.0是否可以自定義或重定向到/令牌url

是否可以將/ token API自定義爲其他內容?

在我的舊制度,OAuth憑證是通過類似的路徑管理 /OAuth的/ client_credential /的accessToken

也許有可能映射/ OAuth的/ client_credential /的accessToken到/令牌這樣既可以用嗎?

回答

0

解決方案Bhathiya建議的作品,只是不得不調整代理端點

<api xmlns="http://ws.apache.org/ns/synapse" name="_WSO2AMTokenAPIProxy_" context="/oauth/client_credential/accesstoken"> 
<resource methods="POST" url-mapping="/*" faultSequence="_token_fault_"> 
    <inSequence> 
     <send> 
      <endpoint> 
       <http uri-template="http://127.0.0.1:8280/token"> 
        <timeout> 
         <duration>60000</duration> 
         <responseAction>fault</responseAction> 
        </timeout> 
       </http> 
      </endpoint> 
     </send> 
    </inSequence> 
    <outSequence> 
     <send/> 
    </outSequence> 
</resource> 

0

如果您只是想更改/ token api的基本路徑,您可以在api管理器前面使用一些反向代理(例如。nginx),或者在api管理器中創建一個像這樣的代理api。

<api xmlns="http://ws.apache.org/ns/synapse" name="_WSO2AMTokenAPIProxy_" context="/oauth/client_credential/accesstoken"> 
    <resource methods="POST" url-mapping="/*" faultSequence="_token_fault_"> 
     <inSequence> 
     <property name="uri.var.portnum" expression="get-property('https.nio.port')"/> 
      <send> 
       <endpoint> 
        <http uri-template="https://localhost:{uri.var.portnum}/token"> 
         <timeout> 
          <duration>60000</duration> 
          <responseAction>fault</responseAction> 
         </timeout> 
        </http> 
       </endpoint> 
      </send> 
     </inSequence> 
     <outSequence> 
      <send/> 
     </outSequence> 
    </resource> 
    <handlers/> 
</api> 

你需要將它複製到<APIM_HOME>/repository/deployment/server/synapse-configs/default/api/_WSO2AMTokenAPIProxy_.xml

+0

感謝@Bhathiya,當我使用時,我得到的錯誤與uri.var.portnum未被評估有關。我硬編碼本地主機:8280,但後來我收到有關CSRF附加警告,挫敗..... – user2725960