Strava OAuth provider

OAuth integration for Strava. Refer to How To Create An Application for getting the required credentials. Provider id is strava.

import { strava } from "@lucia-auth/oauth/providers";
import { auth } from "./lucia.js";

const stravaAuth = strava(auth, config);

strava()#

const strava: (
	auth: Auth,
	config: {
		clientId: string;
		clientSecret: string;
		scope?: string[];
		redirectUri?: string;
	}
) => GithubProvider;
Parameters#
nametypedescriptionoptional
authAuthLucia instance
config.clientIdstringStrava OAuth app client id
config.clientSecretstringStrava OAuth app client secret
config.scopestring[]an array of scopes
config.redirectUristringan authorized redirect URI
Returns#
typedescription
StravaProviderStrava provider

Interfaces#

StravaAuth#

See OAuth2ProviderAuth.

// implements OAuth2ProviderAuth<GithubAuth<_Auth>>
interface StravaAuth<_Auth extends Auth> {
	getAuthorizationUrl: () => Promise<readonly [url: URL, state: string]>;
	validateCallback: (code: string) => Promise<StravaUserAuth<_Auth>>;
}
Generics#
nameextendsdefault
_AuthAuthAuth

StravaTokens#

type  =
  | {
    accessToken: string;
    user: StravaUser;
  }
	| {
    accessToken: string;
    refreshToken: string;
    accessTokenExpiresIn: number;
    user: StravaUser;
  };

StravaUser#

export type StravaUser = {
	id: number;
	username: string;
	resource_state: number;
	firstname: string;
	lastname: string;
	bio: string;
	city: string;
	country: string;
	sex: string;
	premium: boolean;
	summit: boolean;
	created_at: string;
	updated_at: string;
	badge_type_id: number;
	weight: number;
	profile_medium: string;
	profile: string;
};

StravaUserAuth#

Extends ProviderUserAuth.

interface StravaUserAuth<_Auth extends Auth> extends ProviderUserAuth<_Auth> {
	stravaUser: StravaUser;
	stravaTokens: StravaTokens;
}
propertiestypedescription
stravaUserStravaUserStrava user
stravaTokensStravaTokensAccess tokens etc
Generics#
nameextends
_AuthAuth