OauthEntity: CDEK API OAuth tokens in Joomla

WT CDEK library - Documentation
Category: Libraries

OauthEntity in WT CDEK for Joomla covers manual CDEK OAuth token retrieval. This reference explains its purpose, parameters and PHP examples for Joomla extensions.

OauthEntity retrieves OAuth tokens manually. Normal integrations authenticate automatically through CdekRequest; direct access is mainly for debugging and custom workflows.

Access the entity through the Cdek facade:

$oauth = $cdek->oauth();

getOAuthToken()

Signature

public function getOAuthToken(array $request_options = []): array

REST API

  • POST /v2/oauth/token

Purpose

Requests an OAuth token directly.

Parameters

All three fields are required: grant_type, client_id, client_secret. Use grant_type client_credentials.

Returns

An array with access_token, token_type, expires_in, or an error.

Example

<?php

declare(strict_types=1);

use Webtolk\Cdekapi\Cdek;

defined('_JEXEC') or die;

$cdek = new Cdek();

$tokenData = $cdek->oauth()->getOAuthToken([
    'grant_type'    => 'client_credentials',
    'client_id'     => 'your_client_id',
    'client_secret' => 'your_client_secret',
]);

Overview and getting started

WT CDEK 1.4.0 source code on GitHub

WebTolk Joomla Extensions

113 Extensions
12 Categories
587 Versions released
920737 Downloads