CoreFiles by mySites.guru
Oauth2TokenField.php69 lines, 1,881 bytes, from Joomla_6.2.0-Stable-Full_Package.zip
Raw History Compare with 6.1.4
md5
761ef04ae67e6889833bf7b59d34ad31
sha1
145b672d4165ab6a880c7d7eafbe937f52de9693
sha256
34e3b564408a9c36a858a1b25ade1a9afaa2462c1f0fc67eb0dfde40272cf849
<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_config
 *
 * @copyright   (C) 2026 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\Component\Config\Administrator\Field;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

use Joomla\CMS\Form\FormField;
use Joomla\CMS\Uri\Uri;

/**
 * Renders OAuth2 token actions for Global Configuration mail settings.
 *
 * @since  6.2.0
 */
class Oauth2TokenField extends FormField
{
    /**
     * The form field type.
     *
     * @var    string
     * @since  6.2.0
     */
    protected $type = 'Oauth2Token';

    /**
     * The layout to render.
     *
     * @var    string
     * @since  6.2.0
     */
    protected $layout = 'joomla.form.field.oauth2token';

    /**
     * Build the OAuth2 token action UI.
     *
     * @return  string
     *
     * @since   6.2.0
     */
    protected function getInput()
    {

        $formData      = $this->form->getData();
        $clientId      = (string) $formData->get('smtp_oauth2_client_id');
        $refreshToken  = (string) $formData->get('smtp_oauth2_refresh_token');
        $tokenIssuedAt = (string) $formData->get('smtp_oauth2_token_issued_at');

        $data = $this->getLayoutData();

        $data['clientId']      = $clientId;
        $data['refreshToken']  = !empty($refreshToken);
        $data['tokenIssuedAt'] = $tokenIssuedAt;
        $data['callbackUrl']   = Uri::base() . 'index.php?option=com_config&task=mail.oauth2callback&format=raw';
        $data['issueUrl']      = 'index.php?option=com_config&task=mail.oauth2auth';
        $data['checkUrl']      = 'index.php?option=com_config&task=mail.oauth2checktoken';

        return $this->getRenderer($this->layout)->render($data);
    }
}

The same content is in 6 releases, Joomla 6.2.0-beta2 to 6.2.1-rc1. See them all, or every version of this file.