Customer Account Management + Agent Assist feature integration

Edit on GitHub
You are browsing a previous version of the document. The latest version is 202212.0.

Follow the steps below to install the Customer Account Management + Agent Assist feature core.

Prerequisites

To start the feature integration, overview and install the necessary features:

Name Version Integration guide
Customer Account Managemen master Customer Account Management feature integration
Agent Assist master Agent Assist feature integration

1) Install the required modules using Composer

Run the following command to install the required modules:

composer require spryker/oauth-agent-connector:"^1.0.0" --update-with-dependencies
Verification

Ensure that the following module has been installed:

Module Expected Directory
OauthAgentConnector vendor/spryker/oauth-agent-connector

2) Set up configuration

Activate the following plugin:

Plugin Specification Prerequisites Namespace
AgentOauthScopeInstallerPlugin Installs agent-specific OAuth scopes. None Spryker\Zed\OauthAgentConnector\Communication\Plugin\Installer

src/Pyz/Zed/Installer/InstallerDependencyProvider.php

<?php

namespace Pyz\Zed\Installer;

use Spryker\Zed\Installer\InstallerDependencyProvider as SprykerInstallerDependencyProvider;
use Spryker\Zed\OauthAgentConnector\Communication\Plugin\Installer\AgentOauthScopeInstallerPlugin;

class InstallerDependencyProvider extends SprykerInstallerDependencyProvider
{
    /**
     * @return \Spryker\Zed\Installer\Dependency\Plugin\InstallerPluginInterface[]
     */
    public function getInstallerPlugins()
    {
        return [
            new AgentOauthScopeInstallerPlugin(),
        ];
    }
}
Verification

Ensure that console setup:init-db installs agent-specific scopes configured in OauthAgentConnectorConfig::getAgentScopes().

3) Set up transfer objects

Run the following command to generate transfer changes:

console transfer:generate
Verification

Ensure that the following changes have been applied in the transfer objects: | Transfer | Type | Event | Path | | — | — | — | — | | CustomerIdentifierTransfer.idAgent | property | created | src/Generated/Shared/Transfer/CustomerIdentifierTransfer | | OauthScopeTransfer | class | created | src/Generated/Shared/Transfer/OauthScopeTransfer | | OauthUserTransfer | class | created | src/Generated/Shared/Transfer/OauthUserTransfer | | OauthClientTransfer | class | created | src/Generated/Shared/Transfer/OauthClientTransfer | | OauthScopeRequestTransfer | class | created | src/Generated/Shared/Transfer/OauthScopeRequestTransfer | | FindAgentResponseTransfer | class | created | src/Generated/Shared/Transfer/FindAgentResponseTransfer | | OauthGrantTypeConfigurationTransfer | class | created | src/Generated/Shared/Transfer/OauthGrantTypeConfigurationTransfer | | UserTransfer | class | created | src/Generated/Shared/Transfer/UserTransfer |

4) Set up behavior

Activate the following plugins:

Plugin Specification Prerequisites Namespace
AgentOauthUserProviderPlugin Authenticates an Agent, reads Agent data and provides it for the access token. None Spryker\Zed\OauthAgentConnector\Communication\Plugin\Oauth
AgentOauthScopeProviderPlugin Provides the Agent scopes. None Spryker\Zed\OauthAgentConnector\Communication\Plugin\Oauth
AgentCredentialsOauthGrantTypeConfigurationProviderPlugin Provides configuration of theagent_credentials grant type. None Spryker\Zed\OauthAgentConnector\Communication\Plugin\Oauth
src/Pyz/Zed/Oauth/OauthDependencyProvider.php
<?php

namespace Pyz\Zed\Oauth;

use Spryker\Zed\Oauth\OauthDependencyProvider as SprykerOauthDependencyProvider;
use Spryker\Zed\OauthAgentConnector\Communication\Plugin\Oauth\AgentCredentialsOauthGrantTypeConfigurationProviderPlugin;
use Spryker\Zed\OauthAgentConnector\Communication\Plugin\Oauth\AgentOauthScopeProviderPlugin;
use Spryker\Zed\OauthAgentConnector\Communication\Plugin\Oauth\AgentOauthUserProviderPlugin;

class OauthDependencyProvider extends SprykerOauthDependencyProvider
{
    /**
     * @return \Spryker\Zed\OauthExtension\Dependency\Plugin\OauthUserProviderPluginInterface[]
     */
    protected function getUserProviderPlugins(): array
    {
        return [
            new AgentOauthUserProviderPlugin(),
        ];
    }

    /**
     * @return \Spryker\Zed\OauthExtension\Dependency\Plugin\OauthScopeProviderPluginInterface[]
     */
    protected function getScopeProviderPlugins(): array
    {
        return [
            new AgentOauthScopeProviderPlugin(),
        ];
    }

    /**
     * @return \Spryker\Zed\OauthExtension\Dependency\Plugin\OauthGrantTypeConfigurationProviderPluginInterface[]
     */
    protected function getGrantTypeConfigurationProviderPlugins(): array
    {
        return array_merge(parent::getGrantTypeConfigurationProviderPlugins(), [
            new AgentCredentialsOauthGrantTypeConfigurationProviderPlugin(),
        ]);
    }
}
Verification

Ensure that the Agent can get the access token with valid credentials by sending the request:

Request sample

POST https://glue.mysprykershop.com/agent-access-tokens

{
    "data": {
        "type": "agent-access-tokens",
        "attributes": {
            "username": "admin@spryker.com",
            "password": "change123"
        }
    }
}
Expected response
{
    "data": {
        "type": "agent-access-tokens",
        "id": null,
        "attributes": {
            "tokenType": "Bearer",
            "expiresIn": 28800,
            "accessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOi...",
            "refreshToken": "def50200d0f922e0c1e981add4..."
        },
        "links": {
            "self": "https://glue.mysprykershop.com/agent-access-tokens"
        }
    }
}

Install the following related features:

Feature Integration Guide
Customer Account Management Customer Acount Management feature integration
Agent Assist Agent Assist feature integration
Agent Assist API Glue API: Agent Assist feature integration