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#
name | type | description | optional |
---|
auth | Auth | Lucia instance | |
config.clientId | string | Strava OAuth app client id | |
config.clientSecret | string | Strava OAuth app client secret | |
config.scope | string[] | an array of scopes | ✓ |
config.redirectUri | string | an authorized redirect URI | ✓ |
Returns#
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#
name | extends | default |
---|
_Auth | Auth | Auth |
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;
}
Generics#