Skip to content

Commit

Permalink
fix(providers): convert Strava Provider to TS (#5241)
Browse files Browse the repository at this point in the history
* update strava

* add localhost fallback

* lint & small updates

* Update docs/versioned_docs/version-v3/providers/strava.md

Co-authored-by: Lluis Agusti <hi@llu.lu>

* fix

* Delete yarn.lock

* Apply suggestions from code review

Co-authored-by: Lluis Agusti <hi@llu.lu>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
  • Loading branch information
3 people committed Sep 6, 2022
1 parent 78664aa commit f1d3bc2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/versioned_docs/version-v3/providers/strava.md
Expand Up @@ -13,7 +13,7 @@ The **Strava Provider** comes with a set of default options:

- [Strava Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/strava.js)

You can override any of the options to suit your own use case.
You can override any of the options to suit your own use case. Ensure the `redirect_uri` configuration fits your needs accordingly.

## Example

Expand Down
@@ -1,5 +1,15 @@
/** @type {import(".").OAuthProvider} */
export default function Strava(options) {
import type { OAuthConfig, OAuthUserConfig } from "."

export interface StravaProfile extends Record<string, any> {
id: string // this is really a number
firstname: string
lastname: string
profile: string
}

export default function Strava<P extends StravaProfile>(
options: OAuthUserConfig<P>
): OAuthConfig<P> {
return {
id: "strava",
name: "Strava",
Expand All @@ -10,7 +20,6 @@ export default function Strava(options) {
scope: "read",
approval_prompt: "auto",
response_type: "code",
redirect_uri: "http://localhost:3000/api/auth/callback/strava",
},
},
token: {
Expand All @@ -20,11 +29,10 @@ export default function Strava(options) {
client: {
token_endpoint_auth_method: "client_secret_post",
},

profile(profile) {
return {
id: profile.id,
name: profile.firstname,
name: `${profile.firstname} ${profile.lastname}`,
email: null,
image: profile.profile,
}
Expand Down

1 comment on commit f1d3bc2

@vercel
Copy link

@vercel vercel bot commented on f1d3bc2 Sep 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.