PHPackages                             mugnate/oauth2-ecwid - 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. mugnate/oauth2-ecwid

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

mugnate/oauth2-ecwid
====================

Ecwid OAuth 2.0 Client Provider for The PHP League OAuth2-Client

v1.0.2(8y ago)0162↓75%MITPHP

Since Jul 13Pushed 8y ago1 watchersCompare

[ Source](https://github.com/mugnate/oauth2-ecwid)[ Packagist](https://packagist.org/packages/mugnate/oauth2-ecwid)[ RSS](/packages/mugnate-oauth2-ecwid/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (5)Versions (4)Used By (0)

Ecwid Provider for OAuth 2.0 Client
===================================

[](#ecwid-provider-for-oauth-20-client)

[![Latest Version](https://camo.githubusercontent.com/22d4f05b88867d01998c2deb27661b011478dc7a00c2f6ca12667f5cb06e1afb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6d75676e6174652f6f61757468322d65637769642e7376673f7374796c653d666c61742d737175617265)](https://github.com/mugnate/oauth2-ecwid/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/5ec8db2f76d107ddf5e4678db8d552304a09fff1a615fa2bdecdb88f0e9af511/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d75676e6174652f6f61757468322d65637769642f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/mugnate/oauth2-ecwid)[![Quality Score](https://camo.githubusercontent.com/26a26210d9f4b4497198d26b909f048601076d08988a91f9af735d2992bb5f34/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6d75676e6174652f6f61757468322d65637769642e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/mugnate/oauth2-ecwid)[![Total Downloads](https://camo.githubusercontent.com/a6fec28a59237b352e42acbc7788ef33abeeaeb48b0d13b7a74f747d7efe8aa4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d75676e6174652f6f61757468322d65637769642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mugnate/oauth2-ecwid)

This package provides Ecwid () OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).

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

[](#installation)

To install, use composer:

```
composer require mugnate/oauth2-ecwid

```

Usage
-----

[](#usage)

Usage is the same as The League's OAuth client, using `\League\OAuth2\Client\Provider\Ecwid` as the provider.

### Configuration

[](#configuration)

```
$provider = new Mugnate\OAuth2\Client\Provider\Ecwid([
    'clientId'          => '{ecwid-client-id}',
    'clientSecret'      => '{ecwid-client-secret}',
    'redirectUri'       => 'https://yoursite.com/callback-url',
]);
```

### Link

[](#link)

```
$authUrl = $provider->getAuthorizationUrl();
$_SESSION['oauth2-ecwid-state'] = $provider->getState();

echo '';
```

### Callback

[](#callback)

```
if (! isset($_GET['code'])) {
    exit('Invalid code');
}
// Check given state against previously stored one to mitigate CSRF attack
elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2-ecwid-state'])) {

    unset($_SESSION['oauth2-ecwid-state']);
    exit('Invalid state');

} else {

    try {

        // Try to get an access token (using the authorization code grant)
        $token = $provider->getAccessToken('authorization_code', [
            'code' => $_GET['code']
        ]);

    } catch (Exception $e) {

        // Failed to get user details
        exit('Oh dear...');
    }

    // Optional: Now you have a token you can look up a users profile data
    try {

        // We got an access token, let's now get the user's details
        $user = $provider->getResourceOwner($token);

        // Use these details to create a new profile
        printf('Your email %s!', $user->getEmail());

    } catch (Exception $e) {

        // Failed to get user details
        exit('Oh dear...');
    }

    // Use this to interact with an API on the users behalf
    echo $token->getToken();
}
```

### Managing Scopes

[](#managing-scopes)

When creating your Ecwid authorization URL, you can specify the state and scopes your application may authorize.

```
$options = [
    'state' => 'OPTIONAL_CUSTOM_CONFIGURED_STATE',
    'scope' => ['read_store_profile', 'read_catalog', 'read_orders'] // array or string
];

$authorizationUrl = $provider->getAuthorizationUrl($options);
```

Testing
-------

[](#testing)

```
$ ./vendor/bin/phpunit
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/mugnate/oauth2-ecwid/blob/master/CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Nikolay Votintsev](https://github.com/votintsev)
- [All Contributors](https://github.com/mugnate/oauth2-ecwid/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/mugnate/oauth2-ecwid/blob/master/LICENSE) for more information.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

3

Last Release

3216d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ff2a0d80a0a30bce1ea26d5a664dfb5f6fd023394d57c75cfcf07395aea5cef?d=identicon)[votintsev](/maintainers/votintsev)

![](https://www.gravatar.com/avatar/22841cd5000f7b3a8f8db52afa688e9793a3361a8d2450f2cd6874c0980aa907?d=identicon)[mugnate](/maintainers/mugnate)

---

Top Contributors

[![votintsev](https://avatars.githubusercontent.com/u/3229523?v=4)](https://github.com/votintsev "votintsev (11 commits)")

---

Tags

ecwidoauth2Authenticationoauthoauth2authorizationEcwid

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/mugnate-oauth2-ecwid/health.svg)

```
[![Health](https://phpackages.com/badges/mugnate-oauth2-ecwid/health.svg)](https://phpackages.com/packages/mugnate-oauth2-ecwid)
```

###  Alternatives

[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
