POST wreapper for oAuthRequest.

@return mixed
762729
function post($url, $parameters = array(), $multi = false) {
    $response = $this->oAuthRequest($url, 'POST', $parameters, $multi );
    if ($this->format === 'json' && $this->decode_json) {
      return json_decode($response, true);
    }
    return $response;
  }
618186
public function postRemap()
    {
        $oUri    = Factory::service('Uri');
        $iItemId = (int) $oUri->segment(4);
        if ($iItemId && $iItemId != activeUSer('id') && !userHasPermission('admin:auth:accounts:editothers')) {
            return [
                'status' => 401,
                'error'  => 'You do not have permission to update this resource',
            ];
        } elseif (!$iItemId && !userHasPermission('admin:auth:accounts:create')) {
            return [
                'status' => 401,
                'error'  => 'You do not have permission to create this type of resource',
            ];
        }

        return parent::postRemap();
    }
1085298
protected Http buildHttpPostAuthRequest() {
        return new Http(HttpMethod.POST.name(),
            duoProperties.getDuoApiHost(),
            String.format("/auth/v%s/auth", AUTH_API_VERSION));
    }
729269
protected function handlePOST()
    {
        /** @var BaseSystemModel $modelClass */
        $modelClass = static::$model;

        if (!empty($this->resource)) {
            throw new BadRequestException('Create record by identifier not currently supported.');
        }

        $records = ResourcesWrapper::unwrapResources($this->getPayloadData());
        if (empty($records)) {
            throw new BadRequestException('No record(s) detected in request.' . ResourcesWrapper::getWrapperMsg());
        }

        $result = $modelClass::bulkCreate($records, $this->request->getParameters());

        $asList = $this->request->getParameterAsBool(ApiOptions::AS_LIST);
        $idField = $this->request->getParameter(ApiOptions::ID_FIELD, static::getResourceIdentifier());
        $result = ResourcesWrapper::cleanResources($result, $asList, $idField, ApiOptions::FIELDS_ALL);

        return ResponseFactory::create($result, null, ServiceResponseInterface::HTTP_CREATED);
    }
665532
public function resourceAction()
    {
        // Handle a request for an OAuth2.0 Access Token and send the response to the client
        if (!$this->server->verifyResourceRequest($this->getOAuth2Request())) {
            $response   = $this->server->getResponse();
            $parameters = $response->getParameters();
            $errorUri   = isset($parameters['error_uri']) ? $parameters['error_uri'] : null;
            return new ApiProblemResponse(
                new ApiProblem(
                    $response->getStatusCode(),
                    $parameters['error_description'],
                    $errorUri,
                    $parameters['error']
                )
            );
        }
        $httpResponse = $this->getResponse();
        $httpResponse->setStatusCode(200);
        $httpResponse->getHeaders()->addHeaders(array('Content-type' => 'application/json'));
        $httpResponse->setContent(
            json_encode(array('success' => true, 'message' => 'You accessed my APIs!'))
        );
        return $httpResponse;
    }
547162
public function token()
    {
        $response = $this->oauthServer->handleTokenRequest(Request::createFromGlobals());
        if (!$response->isSuccessful()) {
            return $this->response->sendError(
                ResponseCodes::AUTH_ERROR,
                $response->getStatusCode(),
                $response->getParameter('error_description')
            );
        } else {
            return $this->response->sendSuccess($response->getParameters());
        }
    }
1313194
protected function handlePOST()
    {
        $oldPassword = $this->getPayloadData('old_password');
        $newPassword = $this->getPayloadData('new_password');
        $login = $this->request->getParameterAsBool('login');

        if (!empty($oldPassword) && Session::isAuthenticated()) {
            $user = Session::user();

            return static::changePassword($user, $oldPassword, $newPassword, $login);
        }

        $email = $this->getPayloadData('email');
        $username = $this->getPayloadData('username');
        $code = $this->getPayloadData('code');
        $answer = $this->getPayloadData('security_answer');
        $loginAttribute = strtolower(config('df.login_attribute', 'email'));

        if ($this->request->getParameterAsBool('reset')) {
            if ($loginAttribute === 'username') {
                return $this->passwordResetWithUsername($username);
            }

            return $this->passwordReset($email);
        }

        if (!empty($code)) {
            if ($loginAttribute === 'username') {
                return static::changePasswordByCodeWithUsername($username, $code, $newPassword, $login);
            }

            return static::changePasswordByCode($email, $code, $newPassword, $login);
        }

        if (!empty($answer)) {
            if ($loginAttribute === 'username') {
                return static::changePasswordBySecurityAnswerWithUsername($username, $answer, $newPassword, $login);
            }

            return static::changePasswordBySecurityAnswer($email, $answer, $newPassword, $login);
        }

        throw new BadRequestException('Not enough information provided to change password.');
    }
1309095
public function verifyAction()
    {
        $server = $this->get('oauth2.server');

        if (!$server->verifyResourceRequest($this->get('oauth2.request'), $this->get('oauth2.response'))) {
            return $server->getResponse();
        }

        $tokenData = $server->getAccessTokenData($this->get('oauth2.request'), $this->get('oauth2.response'));

        return new JsonResponse($tokenData);
    }
1346460
public function getBearerToken()
	{	
		try { 

			$response = $this->client->request('POST', self::$api_base.'oauth2/token', [
			    'query' => ['grant_type' => 'client_credentials'],
			    'headers' => [
			        'Authorization' => 'Basic ' . base64_encode($this->app_key.':'.$this->app_secret),
			        'Content-Type'     => 'application/x-www-form-urlencoded;charset=UTF-8'
			    ]
			]);

 			$this->setStatusCode($response->getStatusCode());
 			$response_body = json_decode($response->getBody());
 			$this->bearer_token = $this->isBearer($response_body);

 		} catch (\Exception $e) {

			$this->setStatusCode($e->getCode());
			$this->setResponse($e->getMessage());

		}
		
 	}
418934
protected function _getApi()
    {
        $post = AnRequest::get('post', 'string');

        $api = null;

        try {

            if (isset($post['oauth_token']) && isset($post['oauth_handler'])) {
                $api = ComConnectHelperApi::getApi($post['oauth_handler']);
                $api->setToken($post['oauth_token'], isset($post['oauth_secret']) ? $post['oauth_secret'] : '');
            } else {
                $session = new AnConfig(AnRequest::get('session.oauth', 'raw', array()));

                if (! ($session->token && $session->api && $session->consumer)) {
                    return;
                }

                AnRequest::set('session.oauth', null);
                AnService::get('anahita:loader')->loadIdentifier('com:connect.oauth.consumer');

                $api = AnService::get('com:connect.oauth.service.'.$session->api, array(
                    'consumer' => new ComConnectOauthConsumer($session->consumer),
                    'token' => $session->token,
                ));
            }

        } catch (Exception $e) {
            error_log($e->getMessage());
            $api = null;
        }

        return $api;
    }
996080
public function curlPostRequestToken($oauth_callback = '', $proxy = '') {
        $oauth_callback = self::validateString('$oauth_callback', $oauth_callback);
        $proxy          = self::validateString('$proxy', $proxy);
        $url    = 'https://api.twitter.com/oauth/request_token';
        $params = compact('oauth_callback');
        $ch     = self::curlInit($proxy);
        curl_setopt_array($ch, array(
            CURLOPT_HTTPHEADER => $this->getAuthorization($url, 'POST', $params, self::MODE_REQUEST_TOKEN),
            CURLOPT_URL        => $url,
            CURLOPT_POSTFIELDS => http_build_query($params, '', '&'),
            CURLOPT_POST       => true,
        ));
        return $ch;
    }
167715
public function token()
    {
        // Handle the token request
        $response = $this->tokenServer->handleTokenRequest(\OAuth2\Request::createFromGlobals());

        // Get the data as json and convert it to an array,
        // - so we can set our own response type.
        $data = $response->getResponseBody('json');
        $data = json_decode($data, true);

        // Set the response, status code and output content setting final output to true
        $this->response = $data;
        $this->statusCode = $response->getStatusCode();
        $this->output(true);
        return $this;
    }
1233088
public function getAccessToken()
    {
        try {
            $response = $this->post('/oauth/token')->send();
        } catch (ClientErrorResponseException $e) {
            throw OauthException::factory($e->getRequest(), $e->getResponse());
        }
        return new AccessToken($this, $response);
    }
993180
protected function getAuthToken()
    {
        $token = $this->request->getHeader('X_AUTHORIZATION');
        if (!$token) {
            $request = $this->getDI()->get('request');
            $token = $request->getQuery('token') ?: $request->getPost('token');
        }

        $token = trim(str_ireplace('Token:', '', $token));
        if (strlen($token) < 30) {
            throw new HTTPException('Unauthorized access blocked', 401, [
                'dev' => 'Supplied Token: ' . $token,
                'code' => '98914681681864674'
            ]);
        }
        return $token;
    }
55041
protected function getToken()
    {
        /* @var ResponseInterface $response */
        $response = $this->post(self::TOKEN_URI, [
            'body' => [
                'grant_type' => 'authorization_code',
                'code' => $this->getCodeQueryField(),
                'client_id' => $this->clientId,
                'client_secret' => $this->clientSecret
            ]
        ]);

        if ($response->getStatusCode() == 200) {
            $this->setPropertiesBasedOnSuccessResponse($response->json());

            return;
        }

        $response = $response->json();
        throw new OAuthException("{$response['error']}:{$response['error_description']}");
    }
920028
public function getAccessToken()
    {
        return $this->requestHandler->sendRequestAsync('POST', 'api/v4/oauth/access_token/')->then(
            function ($tokenValues) {
                parse_str($tokenValues, $tokenArray);
                $token = $tokenArray['oauth_token'];
                $tokenSecret = $tokenArray['oauth_token_secret'];
                $this->requestHandler->setAccessTokenCredentials($token, $tokenSecret);
                return $tokenArray;
            }
        );
    }
25713
public function post() {
		$json = $this->result->toJson ();
		$this->log->debug ( "AbstractCommand (" . get_class ( $this ) . "): response json: $json" );
		$result = Util::post ( $this->config->slack_webhook_url, $json );
		if (! $result) {
			$this->log->error ( "AbstractCommand: Error sending json: $json to slack hook: " . $this->config->slack_webhook_url );
		}
		return $result;
	}