PHPackages                             tomkita/oauth2-fitbit - 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. tomkita/oauth2-fitbit

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

tomkita/oauth2-fitbit
=====================

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

3101PHP

Since Sep 17Pushed 10y ago1 watchersCompare

[ Source](https://github.com/TomKita/oauth2-fitbit)[ Packagist](https://packagist.org/packages/tomkita/oauth2-fitbit)[ RSS](/packages/tomkita-oauth2-fitbit/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

FitBit Provider for OAuth 2.0 Client
====================================

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

[![Build Status](https://camo.githubusercontent.com/9596f8cd6e689d17b90a05db0b1b48c8880e359a535916d2aee5bd04d6280252/68747470733a2f2f7472617669732d63692e6f72672f546f6d4b6974612f6f61757468322d6669746269742e737667)](https://travis-ci.org/TomKita/oauth2-fitbit)

This package provides Fitbit 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 tomkita/oauth2-fitbit

```

Usage
-----

[](#usage)

See below example but remember to use session\_start()

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new TomKita\OAuth2\Client\Provider\FitBit([
    'clientId'          => '229VL8',
    'clientSecret'      => '1ab24355af90770b820ae1c92faf3429s',
    'redirectUri'       => 'http://fitbit.ngrok.io'
]);

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 get get the user's id
    try {

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

    } catch (Exception $e) {
        // Failed to get user details
    }

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

Testing
-------

[](#testing)

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

License
-------

[](#license)

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

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

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/1b78e53966b9aefaa53ed7b18d23ff360d5f33b46b65eea8de2e4e844090c74b?d=identicon)[tomkita](/maintainers/tomkita)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/tomkita-oauth2-fitbit/health.svg)

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

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[beatswitch/lock

A flexible, driver based Acl package for PHP 5.4+

870304.7k2](/packages/beatswitch-lock)[amocrm/amocrm-api-library

amoCRM API Client

182728.5k6](/packages/amocrm-amocrm-api-library)[vonage/jwt

A standalone package for creating JWTs for Vonage APIs

424.1M4](/packages/vonage-jwt)

PHPackages © 2026

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