/** * Prepare a Request before being sent to the HTTP Client * * @param DropboxResponse $request * * @return array [Request URL, Request Headers, Request Body] */ protected function prepareRequest(DropboxRequest $request) { //Build URL $url = $this->buildUrl($request->getEndpoint(), $request->getEndpointType()); //The Endpoint is content if ($request->getEndpointType() === 'content') { //Dropbox requires the parameters to be passed //through the 'Dropbox-API-Arg' header $request->setHeaders(['Dropbox-API-Arg' => json_encode($request->getParams())]); //If a File is also being uploaded if ($request->hasFile()) { //Content Type $request->setContentType("application/octet-stream"); //Request Body (File Contents) $requestBody = $request->getStreamBody()->getBody(); } else { //Empty Body $requestBody = null; } } else { //The endpoint is 'api' //Request Body (Parameters) $requestBody = $request->getJsonBody()->getBody(); } //Empty body if (is_null($requestBody)) { //Content Type needs to be kept empty $request->setContentType(""); } //Build headers $headers = array_merge($this->buildAuthHeader($request->getAccessToken()), $this->buildContentTypeHeader($request->getContentType()), $request->getHeaders()); //Return the URL, Headers and Request Body return [$url, $headers, $requestBody]; }
/** * Disables the access token * * @return void */ public function revokeAccessToken() { //Access Token $accessToken = $this->getApp()->getAccessToken(); //Request $request = new DropboxRequest("POST", "/auth/token/revoke", $accessToken); // Do not validate the response // since the /token/revoke endpoint // doesn't return anything in the response. // See: https://www.dropbox.com/developers/documentation/http/documentation#auth-token-revoke $request->setParams(['validateResponse' => false]); //Revoke Access Token $response = $this->getClient()->sendRequest($request); }