PHPackages                             edwin-luijten/oauth2-strava - 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. edwin-luijten/oauth2-strava

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

edwin-luijten/oauth2-strava
===========================

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

1.4.0(4y ago)12102.6k—1%1[1 PRs](https://github.com/Edwin-Luijten/oauth2-strava/pulls)MITPHPPHP ^5.6|| ^7.0 || ^8.0

Since Feb 9Pushed 1y ago3 watchersCompare

[ Source](https://github.com/Edwin-Luijten/oauth2-strava)[ Packagist](https://packagist.org/packages/edwin-luijten/oauth2-strava)[ RSS](/packages/edwin-luijten-oauth2-strava/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (5)Versions (12)Used By (0)

Strava Provider for OAuth 2.0 Client
====================================

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

[![Latest Version](https://camo.githubusercontent.com/bc04be28da46bfb2f65c6f66586bfc21ddab1a268fe99462b9d6e178c7469cd7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f656477696e2d6c75696a74656e2f6f61757468322d7374726176612e7376673f7374796c653d666c61742d737175617265)](https://github.com/Edwin-Luijten/oauth2-strava/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/f0c83914b2f3d71c4e3afb6b05459d2d1926a9a47b40065bc741be48c6f18446/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f456477696e2d4c75696a74656e2f6f61757468322d7374726176612f43493f6c6162656c3d4349266c6f676f3d676974687562267374796c653d666c61742d737175617265)](https://github.com/Edwin-Luijten/oauth2-strava/actions?query=workflow%3ACI)[![Codecov Code Coverage](https://camo.githubusercontent.com/4af1bd6dbb4d70dd2b58be31129793b962e51aaa1daf3219f3a330df193f43d1/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f456477696e2d4c75696a74656e2f6f61757468322d7374726176613f6c6162656c3d636f6465636f76266c6f676f3d636f6465636f76267374796c653d666c61742d737175617265)](https://codecov.io/gh/Edwin-Luijten/oauth2-strava)[![Total Downloads](https://camo.githubusercontent.com/fa4ca28d26965f94edcff3b828402c71c229d5104a9fc8d5c73f96e3f4f965a6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656477696e2d6c75696a74656e2f6f61757468322d7374726176612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/edwin-luijten/oauth2-strava)

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

Install
-------

[](#install)

Via Composer

```
$ composer require edwin-luijten/oauth2-strava
```

Usage
-----

[](#usage)

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

```
$provider = new League\OAuth2\Client\Provider\Strava([
    'clientId'     => '{strava-client-id}',
    'clientSecret' => '{strava-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->getFirstName() . ' ' . $user->getLastName());

    } 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](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email :author\_email instead of using the issue tracker.

Credits
-------

[](#credits)

- [Edwin Luijten](https://github.com/Edwin-Luijten)
- [All Contributors](https://github.com/Edwin-Luijten/oauth2-strava/graphs/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 73.9% 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 ~285 days

Recently: every ~529 days

Total

9

Last Release

1466d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.5.0

1.4.0PHP ^5.6|| ^7.0 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1e6993df069a061031d80e7fbbf3d4e51b7d84563b08224b10cad084c1308e8a?d=identicon)[Edwin-Luijten](/maintainers/Edwin-Luijten)

---

Top Contributors

[![Edwin-Luijten](https://avatars.githubusercontent.com/u/1339637?v=4)](https://github.com/Edwin-Luijten "Edwin-Luijten (17 commits)")[![it-can](https://avatars.githubusercontent.com/u/644288?v=4)](https://github.com/it-can "it-can (3 commits)")[![jan-di](https://avatars.githubusercontent.com/u/23323185?v=4)](https://github.com/jan-di "jan-di (2 commits)")[![fbonzon](https://avatars.githubusercontent.com/u/1116761?v=4)](https://github.com/fbonzon "fbonzon (1 commits)")

---

Tags

clientAuthenticationoauthoauth2authorizationstrava

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/edwin-luijten-oauth2-strava/health.svg)

```
[![Health](https://phpackages.com/badges/edwin-luijten-oauth2-strava/health.svg)](https://phpackages.com/packages/edwin-luijten-oauth2-strava)
```

###  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)
