getApiClient

context.getApiClient() Returns the platform API client — the entry point for authorizing the addon against the host platform and calling its public REST API on behalf of the current user. The client exposes authorize / getAccessToken / refreshToken for the token lifecycle and request / get / post / patch / delete for API calls. For OAuth with external providers (Yandex, Google, etc.) use context.authorize(authUrl) (see the External Authorization section) instead.

Return value - ApiClient

// Inside an addon iframe
const context = window.Addon.iframe();

// Get the platform API client
const api = context.getApiClient();

// Authorize the user once, then call the REST API on their behalf
await api.authorize();
const currentUser = await api.get('/api/v1/users/current');
logo
Kaiten
If you have any questions or need help with integration feel free to write us at support@kaiten.ru