Hubspot_Helpers::capture_oauth_tokens()

Capture tokens returned by Automator API.


Return Return

(mixed)


Source Source

File: src/integrations/hubspot/helpers/hubspot-helpers.php

	public function capture_oauth_tokens() {

		if ( automator_filter_input( 'integration' ) !== $this->setting_tab ) {
			return;
		}

		$automator_message = automator_filter_input( 'automator_api_message' );

		if ( empty( $automator_message ) ) {
			return;
		}

		$nonce = wp_create_nonce( 'automator_hubspot_api_authentication' );

		$tokens = (array) Automator_Helpers_Recipe::automator_api_decode_message( $automator_message, $nonce );

		$redirect_url = $this->tab_url;

		if ( $tokens ) {
			$this->store_client( $tokens );
			$redirect_url .= '&connect=1';
		} else {
			$redirect_url .= '&connect=2';
		}

		wp_safe_redirect( $redirect_url );

		die;
	}