client = self::get_client(); $this->client->setClientId(self::$client_id); $this->client->setClientSecret(self::$client_secret); $this->client->setRedirectUri($redirect_uri); $this->client->setScopes( 'https://www.googleapis.com/auth/content' ); return $this->client; } /** * @return \RexFeed\Google\Client */ public static function get_client() { return new RexFeed\Google\Client(); } /** * @return false|mixed|void */ public function get_access_token() { return get_option('rex_google_access_token'); } /** * @return bool */ public function is_authenticate() { $access_token = get_option('rex_google_access_token'); if($access_token == 'null') { return false; } if(!isset($access_token)) { return false; } if ( empty( $access_token ) ) { return false; } if(!$access_token) { return false; } $client = self::get_client(); if(is_array($access_token)) { $client->setAccessToken($access_token); }else { $client->setAccessToken(json_decode($access_token, true)); } if ( $client->isAccessTokenExpired() ) { return false; } return true; } /** * @return string */ public function get_access_token_html() { $client = self::get_client(); $redirect_uri = admin_url( 'admin.php?page=merchant_settings' ); $client->setClientId(self::$client_id); $client->setClientSecret(self::$client_secret); $client->setRedirectUri($redirect_uri); $client->setScopes( 'https://www.googleapis.com/auth/content' ); $loginUrl = $client->createAuthurl(); $btn_html = ''.__('Authenticate', 'rex-product-feed').''; $html = '
'; return $html; } /** * @return string */ public function authorization_success_html() { return ''. __('You are now ready to send feed from Product Feed Manager for WooCommerce to your Google Merchant Center. ', 'rex-product-feed').'🚀
'. __('Your access token has expired. This application uses OAuth 2.0 to Access Google APIs. Please insert the information below and authenticate token for Google Merchant Shop. Generated access token expires after 3600 sec.', 'rex-product-feed').'