@riderize/passport-strava-oauth2

Strava authentication strategy for Passport and Node.js

Showing:

Popularity

Downloads/wk

68

GitHub Stars

7

Maintenance

Last Commit

4mos ago

Contributors

0

Package

Dependencies

1

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Passport Strava Oauth2

Build Badge License NPM bundled Badge NPM version Badge

Strava authentication strategy for Passport and Node.js.

As base I used Passport-Facebook. I just made a few changes to display the data that comes from Strava.

This lib aims to make it easier the Strava authentication with Nodejs apps. By plugging into Passport, Strava authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.

Install

$ npm i @riderize/passport-strava-oauth2

Usage

Configure Strategy

Strava uses the OAuth2 strategy in order to authenticate the users. This strategy requires a callback, that receives these credentials and calls done returning the data of the user logged in as well as options to specify the Client ID, Client Secret and Callback URL.

In order to obtain a Client ID and Client Secret first you have to register an app at Strava.

Basic config:

const StravaStrategy = require('@riderize/passport-strava-oauth2').Strategy;

passport.use(new StravaStrategy({
    clientID: STRAVA_CLIENT_ID,
    clientSecret: STRAVA_CLIENT_SECRET,
    callbackURL: "http://127.0.0.1:3000/auth/strava/callback"
  },
  function(accessToken, refreshToken, profile, done) {
    User.findOrCreate({ stravaId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

With Typescript:

import strategy from '@riderize/passport-strava-oauth2';

const StravaStrategy = strategy.Strategy;

passport.use(new StravaStrategy({
    clientID: STRAVA_CLIENT_ID,
    clientSecret: STRAVA_CLIENT_SECRET,
    callbackURL: "http://127.0.0.1:3000/auth/strava/callback"
  },
  function(accessToken, refreshToken, profile, done) {
    User.findOrCreate({ stravaId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

Types

Acknowledgments

License

The MIT License

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial