2.0.0 • Published 3 years ago

@riderize/passport-strava-oauth2 v2.0.0

Weekly downloads
24
License
MIT
Repository
github
Last release
3 years ago

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

2.0.0

3 years ago

1.1.1

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago