Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

MP_Addon_Netsuite_REST::update_token()

Update access token token.

Contents


Source Source

File: calculator-netsuite-add-on/inc/MP_Addon_Netsuite_REST.php

	private function update_token(){

		$body = array(
			'grant_type' => 'refresh_token',
			'client_id' => $this->get_netsuite_consumer_key(),
			'client_secret' => $this->get_netsuite_consumer_secret(),
			'refresh_token' => $this->get_netsuite_refresh_token(),
		);

		if(is_array($body) && count($body)>0) {
			$body=http_build_query($body);
		}

		$response = wp_remote_post( $this->token_url(), array( 'body' => $body ) );

		$token_request_data = json_decode($response['body'], true);
		if (empty($token_request_data))
			die("Couldn't decode '$token_request_data' as a JSON object");

		if (!isset($token_request_data['access_token']))
			die("Missing expected data from ".print_r($token_request_data, true));

		$this->set_netsuite_access_token($token_request_data);

	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.