Add_Google_Sheet_Integration::has_missing_scope()

Method has_missing_scope


Description Description

Checks the client if it has any missing scope or not.


Top ↑

Return Return

(boolean) True if there is a missing scope. Otherwise, false.


Source Source

File: src/integrations/google-sheet/add-google-sheet-integration.php

	public function has_missing_scope() {

		$client = get_option( '_uncannyowl_google_sheet_settings', array() );

		$scopes = array(
			'https://www.googleapis.com/auth/drive',
			'https://www.googleapis.com/auth/spreadsheets',
			'https://www.googleapis.com/auth/userinfo.profile',
			'https://www.googleapis.com/auth/userinfo.email',
		);

		if ( empty( $client['scope'] ) ) {
			return true;
		}

		$has_missing_scope = false;

		foreach ( $scopes as $scope ) {
			if ( false === strpos( $client['scope'], $scope ) ) {
				$has_missing_scope = true;
			}
		}

		return $has_missing_scope;
	}