PHPackages                             dump-rs/oauth2-bitbucket-lumen - 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. dump-rs/oauth2-bitbucket-lumen

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

dump-rs/oauth2-bitbucket-lumen
==============================

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

1.0(10y ago)00MITPHPPHP &gt;=5.5.0

Since Jul 21Pushed 10y ago1 watchersCompare

[ Source](https://github.com/dump-rs/oauth2-bitbucket-lumen)[ Packagist](https://packagist.org/packages/dump-rs/oauth2-bitbucket-lumen)[ RSS](/packages/dump-rs-oauth2-bitbucket-lumen/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Bitbucket Provider for OAuth 2.0 Client
=======================================

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

[![Latest Version](https://camo.githubusercontent.com/2943fa8fc6c384d705b53232ec6242b1da7d45dbcca43d089d6efe98609ff6ce/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73746576656e6d6167756972652f6f61757468322d6269746275636b65742e7376673f7374796c653d666c61742d737175617265)](https://github.com/stevenmaguire/oauth2-bitbucket/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/3e08f835ea8a4db05ee7042a6d03ba692e24c0ef312aacba596740e41c760d8a/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f73746576656e6d6167756972652f6f61757468322d6269746275636b65742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/stevenmaguire/oauth2-bitbucket)[![Coverage Status](https://camo.githubusercontent.com/fb68cc4245e2f6699fe743c8207e290d9dc2bd0b776130edcb36e3780500e4df/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f73746576656e6d6167756972652f6f61757468322d6269746275636b65742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/stevenmaguire/oauth2-bitbucket/code-structure)[![Quality Score](https://camo.githubusercontent.com/27e173ea1506681105e78a5714c03af193e37bb34a8b828d3a0744b52bb14009/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f73746576656e6d6167756972652f6f61757468322d6269746275636b65742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/stevenmaguire/oauth2-bitbucket)[![Total Downloads](https://camo.githubusercontent.com/de61b8512a69334c0a1c43ffa01a46924237fe476d834a6dbc343eeebec8392d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73746576656e6d6167756972652f6f61757468322d6269746275636b65742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stevenmaguire/oauth2-bitbucket)

This package provides Bitbucket 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 stevenmaguire/oauth2-bitbucket

```

Usage
-----

[](#usage)

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

### Authorization Code Flow

[](#authorization-code-flow)

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

if (!isset($_GET['code'])) {

    // If we don't have an authorization code then get one
    $authUrl = $provider->getAuthorizationUrl();
    $_SESSION['oauth2state'] = $provider->getState();
    header('Location: '.$authUrl);
    exit;

// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {

    unset($_SESSION['oauth2state']);
    exit('Invalid state');

} else {

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

    // 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('Hello %s!', $user->getId());

    } 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();
}
```

Testing
-------

[](#testing)

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

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

[](#contributing)

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

Credits
-------

[](#credits)

- [Steven Maguire](https://github.com/stevenmaguire)
- [All Contributors](https://github.com/stevenmaguire/oauth2-bitbucket/contributors)

License
-------

[](#license)

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

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

3948d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c0461de6960c15d83c98df0976d3f3b5582ac62ad9311c44309e6623329fdae0?d=identicon)[dump-rs](/maintainers/dump-rs)

---

Top Contributors

[![stevenmaguire](https://avatars.githubusercontent.com/u/1851973?v=4)](https://github.com/stevenmaguire "stevenmaguire (10 commits)")

---

Tags

clientoauthoauth2authorizationbitbucketauthorisation

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/dump-rs-oauth2-bitbucket-lumen/health.svg)

```
[![Health](https://phpackages.com/badges/dump-rs-oauth2-bitbucket-lumen/health.svg)](https://phpackages.com/packages/dump-rs-oauth2-bitbucket-lumen)
```

###  Alternatives

[stevenmaguire/oauth2-keycloak

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

2275.9M27](/packages/stevenmaguire-oauth2-keycloak)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1132.5M6](/packages/patrickbussmann-oauth2-apple)[stevenmaguire/oauth2-bitbucket

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

20360.5k4](/packages/stevenmaguire-oauth2-bitbucket)[mollie/oauth2-mollie-php

Mollie Provider for OAuth 2.0 Client

251.7M1](/packages/mollie-oauth2-mollie-php)[omines/oauth2-gitlab

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

36721.5k13](/packages/omines-oauth2-gitlab)

PHPackages © 2026

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