Google_Calendar_Helpers::has_missing_scopes( mixed $token )

Method has_missing_scopes.


Description Description

Checks if the user has missing scopes. Scopes are checked during OAuth consent screen.


Top ↑

Parameters Parameters

$token

(Required) The access token combination.


Top ↑

Return Return

(boolean) True if there are scopes missing. Otherwise, false.


Source Source

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

	public function has_missing_scopes( $token ) {

		if ( ! isset( $token['scope'] ) || empty( $token['scope'] ) ) {
			return true;
		}

		$scopes = array(
			'https://www.googleapis.com/auth/calendar',
			'https://www.googleapis.com/auth/calendar.events',
		);

		$has_missing_scope = false;

		foreach ( $scopes as $scope ) {
			if ( ! str_contains( $token['scope'], $scope ) ) {
				$has_missing_scope = true;
			}
		}

		return $has_missing_scope;

	}