PHPackages                             diglin/oauth2-oro-provider - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. diglin/oauth2-oro-provider

ActiveSymfony-bundle[Authentication &amp; Authorization](/categories/authentication)

diglin/oauth2-oro-provider
==========================

Symfony bundle - OAuth2 Oro Client provider

1.0.3(3y ago)24.4k1MITPHPPHP ^7.1|^8.1

Since Aug 13Pushed 3y ago1 watchersCompare

[ Source](https://github.com/diglin/oauth2-oro-provider)[ Packagist](https://packagist.org/packages/diglin/oauth2-oro-provider)[ RSS](/packages/diglin-oauth2-oro-provider/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (5)Versions (5)Used By (0)

OAuth2 Client for OroPlatform based applications
================================================

[](#oauth2-client-for-oroplatform-based-applications)

Introduction
------------

[](#introduction)

This Symfony 4.x &amp; 5.x Bundle allows you to authenticate and connect to OroPlatform based applications API via the OAUth2 protocol.

This bundle extends the `league/oauth2-client` dependency and will be automatically installed. Fur further information about the dependency, visit the url

Compatibility
-------------

[](#compatibility)

- OroPlatform 4.x &amp; 5.x with OAuth Server active on OroPlatform side
    - See [API Feature activation](https://doc.oroinc.com/api/enabling-api-feature/) and [OAuth Authentification on OroPlatform](https://doc.oroinc.com/api/authentication/oauth/)
- Symfony 4.x | 5.x

Installation
------------

[](#installation)

Via composer:

`composer require diglin/oauth2-oro-provider:^1.0`

### Configuration

[](#configuration)

The default configuration of DiglinOAuth2OroBundle is illustrated below:

```
# Default configuration for extension with alias: "diglin_oauth2_oro"
diglin_oauth2_oro:
    api:

        # Url of the Oro Application, without trailing slash
        url:                  ~ # Required

        # Client ID: see documentation to get the value
        client_id:            ~ # Required

        # Client secret: see documentation to get the value
        client_secret:        ~ # Required

        # Username: required if grant_type = password
        username:             null

        # Password: required if grant_type = password
        password:             null

        # grant_type possible values: client_credentials or password
        grant_type:           client_credentials # Required

```

Create a file at the path `config/packages/diglin_oauth2_oro.yaml` (you can set also this file at environment level, like into the prod or dev folder.) with the following content example:

```
parameters:
 'env(OROCRM_URL)': ''
 'env(OROCRM_CLIENT_ID)': ''
 'env(OROCRM_CLIENT_SECRET)': ''

diglin_oauth2_oro:
 api:
  url: "%env(OROCRM_URL)%"
  client_id: '%env(OROCRM_CLIENT_ID)%'
  client_secret: '%env(OROCRM_CLIENT_SECRET)%'
  username: ~ # value only if grant_type = password
  password: ~ # value only if grant_type = password
  grant_type: "client_credentials" # client_credentials or password
```

- `url`: should looks like `https://my-domain.com`
- `client_id` and `client_secret`: you can get the value from OroPlatform - see
- `grant_type`: can be `password` or `client_credentials`. `client_credentials` is recommended

As stated in Oro Documentation:

The Client Credentials type is used for machine-to-machine authentication (e.g. in a cron job that performs maintenance tasks over an API) and Password is used by trusted first-party clients to exchange the credentials (username and password) for an access token. OAuth advises to use `client_credentials`

Usage
-----

[](#usage)

Create an Endpoint implementing the `\Diglin\OAuth2OroBundle\Api\Endpoints\EndpointInterface` interface. Your class can looks like this:

```
