CoreFiles by mySites.guru
Oauth2TokenField.php68 lines, 1,887 bytes, from Joomla_6.3.0-alpha1-Alpha-Full_Package.zip
Raw History Compare with 6.2.0-alpha3
md5
711069a324ed51115d91cc056facaa10
sha1
e763b3395062fd6ff7c643d202d69725abd38210
sha256
e43196fcbaa51f040a031dabb506c1bc40b22eaba3102938bd6fc3a1e3f3b7d8
<?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) $this->getAttribute('refreshToken');
        $tokenIssuedAt = (string) $formData->get('smtp_oauth2_token_issued_at');

        $data = $this->getLayoutData();

        $data['clientId']      = $clientId;
        $data['refreshToken']  = strtolower($refreshToken) === 'true';
        $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 2 releases, Joomla 6.2.1 to 6.3.0-alpha1. See them all, or every version of this file.