Google_Calendar_Helpers::get_authentication_url()

Method get_authentication_url.

Contents


Return Return

(string) The OAuth consent screen url.


Source Source

File: src/integrations/google-calendar/helpers/google-calendar-helpers.php

	public function get_authentication_url() {

		// Create nonce.
		$nonce = wp_create_nonce( 'automator_api_google_calendar_authorize' );

		// Construct the redirect uri.
		$redirect_uri = add_query_arg(
			array(
				'action' => 'automator_google_calendar_process_code_callback',
				'nonce'  => $nonce,
			),
			admin_url( 'admin-ajax.php' )
		);

		set_transient( 'automator_api_google_authorize_nonce', $nonce, 3600 );

		// Construct the OAuth uri.
		$auth_uri = add_query_arg(
			array(
				'action'       => 'authorization_request',
				'redirect_url' => rawurlencode( $redirect_uri ),
				'nonce'        => $nonce,
				'plugin_ver'   => InitializePlugin::PLUGIN_VERSION,
			),
			AUTOMATOR_API_URL . 'v2/google-calendar'
		);

		return $auth_uri;
	}