PHPackages                             league/oauth1-bitbucket - 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. league/oauth1-bitbucket

ActiveLibrary

league/oauth1-bitbucket
=======================

Bitbucket OAuth 1.0 Client Provider for The PHP League OAuth1-Client

392PHP

Since Dec 8Pushed 10y ago5 watchersCompare

[ Source](https://github.com/thephpleague/oauth1-bitbucket)[ Packagist](https://packagist.org/packages/league/oauth1-bitbucket)[ RSS](/packages/league-oauth1-bitbucket/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Bitbucket Provider for OAuth 1.0 Client
=======================================

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

[![Latest Version](https://camo.githubusercontent.com/12e0c1b90db8a17aff519d2d4fc50f58c5deabb721dbbb63aded6414a3395091/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7468657068706c65616775652f6f61757468312d6269746275636b65742e7376673f7374796c653d666c61742d737175617265)](https://github.com/thephpleague/oauth1-bitbucket/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/b79bed801f4f6723c48db03a4a65ccd22c93a92d72e4d1c3877f936bbd440f99/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7468657068706c65616775652f6f61757468312d6269746275636b65742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/thephpleague/oauth1-bitbucket)[![Coverage Status](https://camo.githubusercontent.com/7629e48c677087583ab526fd472fdd01f3c076ff43ba8c4b2bec7738b8ed1233/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f7468657068706c65616775652f6f61757468312d6269746275636b65742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/thephpleague/oauth1-bitbucket/code-structure)[![Quality Score](https://camo.githubusercontent.com/24b4036135d79a1f16bbfb249f6cd893e8039825138ce838b1ac1f00c76bded2/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7468657068706c65616775652f6f61757468312d6269746275636b65742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/thephpleague/oauth1-bitbucket)[![Total Downloads](https://camo.githubusercontent.com/4a4a2e725708f881b13e1c50fe48a72ce8351e077600bf99423632826ee56c58/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c65616775652f6f61757468312d6269746275636b65742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/league/oauth1-bitbucket)

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

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

[](#installation)

To install, use composer:

```
composer require league/oauth1-bitbucket

```

Usage
-----

[](#usage)

Usage is the same as The League's OAuth client, using `\League\OAuth1\Client\Server\Bitbucket` as the server.

### Authenticating with OAuth 1.0

[](#authenticating-with-oauth-10)

```
// Create a server instance.
$server = new \League\OAuth1\Client\Server\Bitbucket([
    'identifier'              => 'your-identifier',
    'secret'                  => 'your-secret',
    'callbackUri'             => 'http://your-callback-uri/',
]);

// Obtain Temporary Credentials and User Authorization
if (!isset($_GET['oauth_token'], $_GET['oauth_verifier'])) {

    // First part of OAuth 1.0 authentication is to
    // obtain Temporary Credentials.
    $temporaryCredentials = $server->getTemporaryCredentials();

    // Store credentials in the session, we'll need them later
    $_SESSION['temporary_credentials'] = serialize($temporaryCredentials);
    session_write_close();

    // Second part of OAuth 1.0 authentication is to obtain User Authorization
    // by redirecting the resource owner to the login screen on the server.
    // Create an authorization url.
    $authorizationUrl = $server->getAuthorizationUrl($temporaryCredentials);

    // Redirect the user to the authorization URL. The user will be redirected
    // to the familiar login screen on the server, where they will login to
    // their account and authorize your app to access their data.
    header('Location: ' . $authorizationUrl);
    exit;

// Obtain Token Credentials
} else {

    try {

        // Retrieve the temporary credentials we saved before.
        $temporaryCredentials = unserialize($_SESSION['temporary_credentials']);

        // We will now obtain Token Credentials from the server.
        $tokenCredentials = $server->getTokenCredentials(
            $temporaryCredentials,
            $_GET['oauth_token'],
            $_GET['oauth_verifier']
        );

        // We have token credentials, which we may use in authenticated
        // requests against the service provider's API.
        echo $tokenCredentials->getIdentifier() . "\n";
        echo $tokenCredentials->getSecret() . "\n";

        // Using the access token, we may look up details about the
        // resource owner.
        $resourceOwner = $server->getResourceOwner($tokenCredentials);

        var_export($resourceOwner->toArray());

        // The server provides a way to get an authenticated API request for
        // the service, using the access token; it returns an object conforming
        // to Psr\Http\Message\RequestInterface.
        $request = $server->getAuthenticatedRequest(
            'GET',
            'http://your.service/endpoint',
            $tokenCredentials
        );

    } catch (\League\OAuth1\Client\Exceptions\Exception $e) {

        // Failed to get the token credentials or user details.
        exit($e->getMessage());

    }

}
```

Testing
-------

[](#testing)

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

```
$ ./vendor/bin/phpcs src --standard=psr2 -sp
```

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

[](#contributing)

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

Credits
-------

[](#credits)

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

License
-------

[](#license)

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

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8d9c05a30823ae19fc54aa4b4721a696c253f8dec10c7fd22d372cfdc0fcb36d?d=identicon)[stevenmaguire](/maintainers/stevenmaguire)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/league-oauth1-bitbucket/health.svg)

```
[![Health](https://phpackages.com/badges/league-oauth1-bitbucket/health.svg)](https://phpackages.com/packages/league-oauth1-bitbucket)
```

PHPackages © 2026

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