getAccessToken example

'id' => $fileId, 'accessToken' => $token]],
            $context
        );

        return $token;
    }

    public function createFileResponse(Context $context, string $fileId, string $accessToken): Response
    {
        $entity = $this->findFile($context$fileId);

        $fileAccessToken = (string) $entity->getAccessToken();

        if ($fileAccessToken === '' || $entity->getAccessToken() !== $accessToken || !$this->isModifiedRecently($entity)) {
            throw ImportExportException::invalidFileAccessToken();
        }

        $this->fileRepository->update(
            [['id' => $fileId, 'accessToken' => null]],
            $context
        );

        $originalName = (string) preg_replace('/[\/\\\]/', '', $entity->getOriginalName());

        

    public function getToken($shopwareId = null, $password = null)
    {
        try {
            return $this->storeClient->getAccessToken($shopwareId$password);
        } catch (StoreException $se) {
            throw $this->translateExceptionMessage($se);
        }
    }

    private function translateExceptionMessage(StoreException $exception): Exception
    {
        $namespace = $this->snippetManager
            ->getNamespace('backend/plugin_manager/exceptions');

        if ($namespace->offsetExists($exception->getMessage())) {
            
$this->repository->create(array_values($data)$this->context);

        foreach ($data as $expect) {
            $id = $expect['id'];
            $result = $this->repository->search(new Criteria([$id])$this->context);
            $importExportFile = $result->get($id);
            static::assertEquals(1, $result->count());
            static::assertEquals($expect['originalName']$importExportFile->getOriginalName());
            static::assertEquals($expect['path']$importExportFile->getPath());
            static::assertEquals(new \DateTime($expect['expireDate'])$importExportFile->getExpireDate());
            static::assertEquals($expect['size']$importExportFile->getSize());
            static::assertEquals($expect['accessToken']$importExportFile->getAccessToken());
        }
    }

    public function testImportExportFileReadNoResult(): void
    {
        $num = 3;
        $data = $this->prepareImportExportFileTestData($num);

        $this->repository->create(array_values($data)$this->context);

        $result = $this->repository->search(new Criteria([Uuid::randomHex()])$this->context);
        
if (empty($password)) {
                $password = $this->io->askHidden('Password');
            }
        }

        try {
            $this->io->section('Community Store Authentication');
            $this->io->comment('Connection to store...');

            /** @var StoreClient $storeClient */
            $storeClient = $this->container->get(StoreClient::class);
            $token = $storeClient->getAccessToken($username$password);

            $this->io->comment('Authenticated successfully.');
        } catch (StoreException $e) {
            $this->io->error('Login failed. Please check your credentials.');
            exit(1);
        }

        return $token;
    }

    /** * Clear opcode caches to make sure that the * updated plugin files are used in the following requests. */
/** @var PluginLicenceService $licenceService */
        $licenceService = $this->get(\Shopware\Bundle\PluginInstallerBundle\Service\PluginLicenceService::class);

        /** @var AccountManagerService $accountService */
        $accountService = $this->get(\Shopware\Bundle\PluginInstallerBundle\Service\AccountManagerService::class);

        $request = new UpdateLicencesRequest(
            $this->getVersion(),
            $this->getLocale(),
            $accountService->getDomain(),
            $this->getAccessToken()
        );

        try {
            $result = $licenceService->updateLicences($request);
        } catch (Exception $e) {
            $this->handleException($e);

            return;
        }

        $plugins = $pluginCheck->checkInstalledPluginsAvailableForNewVersion($this->getVersion());

        
/** * @return void */
    public function metaDownloadAction()
    {
        try {
            $request = new MetaRequest(
                $this->Request()->getParam('technicalName'),
                $this->getVersion(),
                $this->getDomain(),
                $this->getAccessToken()
            );

            $result = $this->get('shopware_plugininstaller.plugin_download_service')->getMetaInformation($request);
            $this->get('backendsession')->offsetSet('plugin_manager_meta_download', $result);
        } catch (Exception $e) {
            $this->handleException($e);

            return;
        }

        $this->View()->assign(['success' => true, 'data' => $result]);
    }
$this->connection->createQueryBuilder()
            ->insert('refresh_token')
            ->values([
                'id' => ':id',
                'user_id' => ':userId',
                'token_id' => ':tokenId',
                'issued_at' => ':issuedAt',
                'expires_at' => ':expiresAt',
            ])
            ->setParameters([
                'id' => Uuid::randomBytes(),
                'userId' => Uuid::fromHexToBytes($refreshTokenEntity->getAccessToken()->getUserIdentifier()),
                'tokenId' => $refreshTokenEntity->getIdentifier(),
                'issuedAt' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
                'expiresAt' => $refreshTokenEntity->getExpiryDateTime()->format(Defaults::STORAGE_DATE_TIME_FORMAT),
            ])
            ->executeStatement();

        $this->cleanUpExpiredRefreshTokens();
    }

    /** * {@inheritdoc} */
$passwordQuestion
                );
            }
        }

        if (empty($username) || empty($password)) {
            throw new Exception('Username and password are required');
        }

        $output->writeln(sprintf('Connect to Store with username: %s...', $username));

        return $this->container->get(\Shopware\Bundle\PluginInstallerBundle\StoreClient::class)->getAccessToken(
            $username,
            $password
        );
    }

    /** * @throws Exception * * @return string */
    protected function setupDomain(InputInterface $input, OutputInterface $output)
    {
'outboundSMSTextMessage' => [
                    'message' => $message->getSubject(),
                ],
            ],
        ];

        if (null !== $this->senderName) {
            $payload['outboundSMSMessageRequest']['senderName'] = urlencode($this->senderName);
        }

        $response = $this->client->request('POST', $url[
            'auth_bearer' => $this->getAccessToken(),
            'json' => $payload,
        ]);

        if (201 !== $response->getStatusCode()) {
            $content = $response->toArray(false);
            $errorMessage = $content['requestError']['serviceException']['messageId'] ?? '';
            $errorInfo = $content['requestError']['serviceException']['text'] ?? '';

            throw new TransportException(sprintf('Unable to send the SMS: "%s" (%s).', $errorMessage$errorInfo)$response);
        }

        
Home | Imprint | This part of the site doesn't use cookies.