Class: Spree::Api::V2::Tenant::TelegramOauthTokensController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/api/v2/tenant/telegram_oauth_tokens_controller.rb

Overview

Identical PKCE code->id_token relay as Storefront::TelegramOauthTokensController, but scoped to the tenant behind the Doorkeeper app access token (see Tenant::BaseController#require_tenant), exposed under /api/v2/tenant so tenant-scoped clients can call it alongside /api/v2/tenant/token

Instance Method Summary collapse

Methods inherited from BaseController

#current_vendor, #render_serialized_payload, #require_tenant, #scope

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/spree/api/v2/tenant/telegram_oauth_tokens_controller.rb', line 10

def create
  return render_error_payload(credential_mismatch_message) if credential_mismatch_message

  result = SpreeCmCommissioner::Telegram::ExchangeOauthToken.call(
    exchange_params.merge(client_secret: resolved_client_secret)
  )

  return render_error_payload(result.error) unless result.success?

  render json: result.value[:body], status: result.value[:status], content_type: 'application/json'
end