取得使用者帳號的服務區

  • 伺服器:ServicePortal

  • 目的:藉以查詢使用者所屬服務區。透過此 API,將依使用者 ID 查詢所屬服務區域中服務匣道伺服器 (ServiceGateway) 位址;透過 ServiceGateway 取得授權並取得服務區域內各服務伺服器位址後,才能進行其他 API 操作。

POST /member/requestservicegateway/

Input

<!--?xml version="1.0" encoding="utf-8" ?--> 
<requestservicegateway>
  <userid>{ User ID }</userid>
  <service>[ 1 ]</service>
</requestservicegateway>

Output

<!--?xml version="1.0" encoding="utf-8" ?--> 
<requestservicegateway>
  <status>{ Status Code }</status>
  <servicegateway>{ ServiceGateway的host:port。例如:192.168.1.20:8080 }</servicegateway>
</requestservicegateway>

回傳的狀態碼(Status Code)

狀態碼

狀態描述

0

Success。

2

Authentication Fail。

999

General Error。


使用者帳號密碼身份認證

  • 伺服器:ServiceGateway

  • 目的:接受客戶端認證的要求,透過使用者帳號、密碼的驗證,以取得授權金鑰 (Token),並回傳此 Service Area 中各 Server 的位址,以進行其他 API 的操作。
    /member/acquiretoken/ 這個 API 會給予客戶端一個在後續執行任何 API 時,用來驗證用戶身份所必須的 Token。除此之外,另一個重要的功能是提供所在之 Service Area 內各種伺服器的位置資訊給客戶端。
    目前計有下列數種伺服器的位置會透過這個 API 回傳給客戶端程式:

    • InfoRelay:在 Payload 中以<inforelay>表示,記錄 InfoRelay IP 位址與埠號。支援檔案、目錄的新增、刪除和修改名稱…等,處理無關檔案實體內容異動的作業。

    • WebRelay:在 Payload 中以<webrelay>表示,記錄 WebRelay IP 位址與埠號。提供了檔案上傳下載相關的服務。

    • Search Server:在 Payload 中以<searchserver>表示,記錄 Search Server IP 位址與埠號。支援檔案、目錄名稱的搜尋。

開發者授權傳送規格:

  1. 在 Cookie 中指定 sid 欄位, Cookie 中的 sid 必須為小寫英文字母。

  2. 在 Header 中必須帶入 Authorization Header ,包含 signature_method、timestamp、nonce 以及 signature 四個參數:

    • nonce:唯一且僅有的亂數,此值在60分鐘內不可重覆出現相同的值。

    • signature_method:hash 的方式,目前提供以 HMAC-SHA1 演算法做 Hash。

    • timestamp:從1970/01/01 00:00:00到現在為止的毫秒數。

    • signature:將上述三參數,依字母排列規格以 Query String 方式串接後做 URLEncode,再以 ProgKey 為 Key 值,進行指定 signature_method 的 Hash 演算,再將 Hash 過的字串加以, Base64 的轉換,最後再將 Base64 後的結果,再進行一次, URLEncode 的字串,即為 signature 字串。

※ 上述細節可參考 OAuth 實作規則中各參數內容的設定方式。
※ 若您使用的開發語言為 Ruby,請用 Base64.strict_encode64,避免 \n 在編碼之後出現。

系統會透過指定的 signature_method,將以上三參數串接並演算後與 signature 比對,若發現內容不相等,則會得到 Status = 5 的錯誤代碼。

URLEncode 後的結果字串中,所有16進位的英文字 (A~F) 都必須為大寫,否則進行 Hash 後的結果會有所不同。

POST /member/acquiretoken/

Input

<!--?xml version="1.0" encoding="utf-8" ?--> 
<aaa>
  <userid>{ User ID }</userid>
  <symmetrypwd>{ 使用者密碼經 Triple DES 加密後的字串 }</symmetrypwd>
  <time>{ time stamp, this is for scramble the payload }</time>
</aaa>

Output

<!--?xml version="1.0" encoding="utf-8" ?--> 
<aaa>
  <status>{ Status Code }</status>
  <token>{ token }</token> 
  
  <!-- 以下 IP:PORT 資料,不填寫 PORT 時預設值為 80 --> 
  <inforelay>{ InfoRelay 的 IP:PORT Ex: 192.168.1.201:8081 }</inforelay>
  <webrelay>{ WebRelay 的IP:PORT }</webrelay>
  <searchserver>{ Search Server 的IP:Port }</searchserver> 
  <package>
    <id>{ Package ID }</id>
    <display>{ EeePC-20G }</display><!-- package name --> 
    <capacity>{ 容量大小。Ex:2000 }</capacity><!-- 計量單位 MB --> 
    <uploadbandwidth>{ 頻寬。Ex:128 }</uploadbandwidth><!-- 計量單位 KB --> 
    <downloadbandwidth>{ 頻寬。Ex:128 }</downloadbandwidth><!-- 計量單位 KB --> 
    <upload>{ Ex:128 }</upload><!-- 計量單位 MB --> 
    <download>{ Ex:128 }</download><!-- 計量單位 MB --> 
    <concurrentsession>{ # 幾個 session(數值) }</concurrentsession> 
    <maxfilesize>{ 數值 }</maxfilesize><!-- 單位為 MB --> 
    <hasencryption>[ 0 | 1 ]</hasencryption> 
    <expire>{ 到期日(格林威治時間),yyyy-MM-dd HH:mm:ss }</expire> 
    <maxbackuppc>{ 備份電腦數上限 }</maxbackuppc> 
  </package> 
  
  <!-- 當 Status Code 為 504、508 時表示必須使用 Auxiliary Password 驗證 --> 
  <auxpasswordurl>{ 若為 OTP 則此欄為空字串 | 若為 CAPTCHA 則此欄為圖型驗證碼的 URL(網址經過URL encoded) }</auxpasswordurl> 
  <time>{ time stamp, this is for different the payload }</time> 
</aaa>

回傳的狀態碼(Status Code)

狀態碼

狀態描述

0

Success。

2

User Authentication Fail。

5

Developer Authentication Fail。sid 不存在或 ProgKey 驗證失敗。

504

OTP 認證失敗。也就是輸入的 User ID / password / OTP 不正確或須使用 OTP 認證卻未輸入 OTP。

505

OTP 服務的 Credential ID 處於 LOCKED 狀態。

508

CAPTCHA 認證失敗,或密碼輸入錯誤次數已超過系統設定值,使用者必須輸入 CAPTCHA,進行驗證。

999

General Error。

MD5 編碼注意事項

若您的 MD5 編碼未經過十六進制轉換,請務必在 MD5 編碼過後,再以十六進位轉換。十六進位所使用的「a,b,c,d,e,f」字母須為小寫。