PHPackages                             waytohealth/oauth2-withings - 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. waytohealth/oauth2-withings

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

waytohealth/oauth2-withings
===========================

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

3.0.0(4y ago)214.8k—0%9[1 issues](https://github.com/waytohealth/oauth2-withings/issues)[1 PRs](https://github.com/waytohealth/oauth2-withings/pulls)MITPHPPHP &gt;=5.6.0

Since Dec 31Pushed 4y ago2 watchersCompare

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

READMEChangelog (4)Dependencies (7)Versions (6)Used By (0)

Withings Provider for OAuth 2.0 Client
======================================

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

[![CI](https://github.com/waytohealth/oauth2-withings/actions/workflows/ci.yml/badge.svg)](https://github.com/waytohealth/oauth2-withings/actions/workflows/ci.yml)

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

This package is compliant with [PSR-1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md), [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md), [PSR-4](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md), and [PSR-7](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-7-http-message.md). If you notice compliance oversights, please send a patch via pull request.

Requirements
------------

[](#requirements)

The following versions of PHP are supported.

- PHP 5.6
- PHP 7.0
- PHP 7.1
- HHVM

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

[](#installation)

To install, use composer:

```
composer require waytohealth/oauth2-withings

```

Usage
-----

[](#usage)

### Authorization Code Grant

[](#authorization-code-grant)

```
use waytohealth\OAuth2\Client\Provider\Withings;

$provider = new Withings([
    'clientId'          => '{withings-oauth2-client-id}',
    'clientSecret'      => '{withings-client-secret}',
    'redirectUri'       => 'https://example.com/callback-url'
]);

// Fetch the authorization URL from the provider; this returns the
// urlAuthorize option and generates and applies any necessary parameters
// (e.g. state).
$authorizationUrl = $provider->getAuthorizationUrl($options);

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

// Add subscription
$subscriptionUrl = sprintf('https://wbsapi.withings.net/notify?action=subscribe&access_token=%s&callbackurl=%s&appli=%s&comment=Way_To_Health',
    $accessToken,
    $params['callbackurl'],
    $params['appli']
);
$subscriptionRequest = $provider->getAuthenticatedRequest('GET', $subscriptionUrl, $accessToken, $options);
$provider->getParsedResponse($request);

// Get data
$request = $provider->getAuthenticatedRequest('GET', $url, $accessToken, $options);
$data = $provider->getParsedResponse($request);
```

### Refreshing a Token

[](#refreshing-a-token)

Once your application is authorized, you can refresh an expired token using a refresh token rather than going through the entire process of obtaining a brand new token. To do so, simply reuse this refresh token from your data store to request a refresh.

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

$existingAccessToken = getAccessTokenFromYourDataStore();

if ($existingAccessToken->hasExpired()) {
    $newAccessToken = $provider->getAccessToken('refresh_token', [
        'refresh_token' => $existingAccessToken->getRefreshToken()
    ]);

    // Purge old access token and store new access token to your data store.
}
```

Testing
-------

[](#testing)

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

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

[](#contributing)

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

License
-------

[](#license)

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

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~311 days

Total

4

Last Release

1762d ago

Major Versions

v1.0.1 → v2.0.02019-07-03

v2.0.0 → 3.0.02021-07-21

### Community

Maintainers

![](https://www.gravatar.com/avatar/3735b69d141bc99aa32600e9a0493cf1f592c27097407b8755717783fee409b9?d=identicon)[mcgrogan91](/maintainers/mcgrogan91)

---

Top Contributors

[![mcgrogan91](https://avatars.githubusercontent.com/u/3495617?v=4)](https://github.com/mcgrogan91 "mcgrogan91 (15 commits)")[![mkopinsky](https://avatars.githubusercontent.com/u/591435?v=4)](https://github.com/mkopinsky "mkopinsky (8 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")[![acleitner](https://avatars.githubusercontent.com/u/3340567?v=4)](https://github.com/acleitner "acleitner (4 commits)")[![benirose](https://avatars.githubusercontent.com/u/2953531?v=4)](https://github.com/benirose "benirose (4 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")[![lostfocus](https://avatars.githubusercontent.com/u/45055?v=4)](https://github.com/lostfocus "lostfocus (1 commits)")

---

Tags

clientAuthenticationoauthoauth2authorizationwithings

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/waytohealth-oauth2-withings/health.svg)

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

###  Alternatives

[league/oauth2-google

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

42121.2M118](/packages/league-oauth2-google)[cakedc/oauth2-cognito

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

18597.7k](/packages/cakedc-oauth2-cognito)

PHPackages © 2026

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