Quellcode durchsuchen

#2634 API: revoke token

Alex Trofimov vor 6 Jahren
Ursprung
Commit
a42810c63d
1 geänderte Dateien mit 38 neuen und 0 gelöschten Zeilen
  1. 38 0
      modules/boonex/oauth2/classes/BxOAuthModule.php

+ 38 - 0
modules/boonex/oauth2/classes/BxOAuthModule.php

@@ -190,6 +190,44 @@ class BxOAuthModule extends BxDolModule
         $this->_oServer->handleTokenRequest(OAuth2\Request::createFromGlobals())->send();
     }
 
+    /**
+     * @page public_api API Public
+     * @section public_api_token /m/oauth2/revoke
+     * 
+     * Revoke token 
+     * 
+     * **HTTP Method:** 
+     * `POST`
+     *
+     * **Request params:**
+     * - `token` - token to revoke
+     *
+     * **Request header:**
+     * @code
+     * Authorization: Bearer 9802c4a34e1535d8c3b721604ee0e7fb04116c49
+     * @endcode
+     *
+     * **Response (success):**
+     * @code
+     * {  
+     *    "revoked":true,
+     * }
+     * @endcode
+     *
+     * **Response (error):**
+     * @code
+     * {  
+     *    "error":"short error description here",
+     *    "error_description":"long error description here"
+     * }
+     * @endcode
+     */
+    function actionRevoke ()
+    {
+        $this->initOAuth($this->getClientIdFromAccessTokenHeader());
+        $this->_oServer->handleRevokeRequest(OAuth2\Request::createFromGlobals())->send();
+    }
+
     /**
      * Authenicated or public call to the "safe" and "public" service methods 
      */