1. Go to this page and download the library: Download diglin/oauth2-oro-provider library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
diglin / oauth2-oro-provider example snippets
namespace Acme\Oro;
use Diglin\OAuth2OroBundle\Api\ClientOAuthInterface;
class MyEndpoint implements \Diglin\OAuth2OroBundle\Api\Endpoints\EndpointInterface
{
const ENDPOINT_CUSTOMER = '/api/users';
const TYPE = 'users';
public function __construct(private ClientOAuthInterface $client)
{
}
public function get()
{
return $this->client->request(ClientOAuthInterface::REQUEST_GET, $this->getEndpoint());
}
// When creating a new entity entry
public function put(array $data = ['my_attribute' => 'my value'])
{
$myJsonData = \json_encode([
'data' => [
'type' => self::TYPE,
'attributes' => $data
],
]);
return $this->client->request(ClientOAuthInterface::REQUEST_PUT, $this->getEndpoint(), ['body' => $myJsonData]);
}
// When updating existing entity entry
public function post(array $data = ['my_attribute' => 'my value'])
{
$myJsonData = \json_encode([
'data' => [
'type' => self::TYPE,
'attributes' => $data
],
]);
return $this->client->request(ClientOAuthInterface::REQUEST_POST, $this->getEndpoint(), ['body' => $myJsonData]);
}
public function getEndpoint(): string
{
return self::ENDPOINT_CUSTOMER;
}
}
// ers = $container->get('diglin_oauth2_oro.api');
$settings = new Diglin\OAuth2OroBundle\Api\ClientOAuthSettings($parameters['url'], $parameters['client_id'], $parameters['client_secret'], $parameters['client_credentials'], $parameters['username'], $parameters['password']);
$factory = new \Diglin\OAuth2OroBundle\Api\ClientOAuthFactory(\Diglin\OAuth2OroBundle\Api\ClientOAuth::class, $settings);
$endpoint = new \Acme\Oro\MyEndpoint($factory->create());
$users = $endpoint->get();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.