Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Strava Provider #5241

Merged
merged 8 commits into from Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 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.
Copy link
Member

Choose a reason for hiding this comment

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

@michaelangrivera my bad, but this was actually done in the wrong file! This is the v3 (unmaintained) documentation. Could you apply this change here in a follow-up PR: https://github.com/nextauthjs/next-auth/blob/main/docs/docs/providers/strava.md

Copy link
Contributor Author

Choose a reason for hiding this comment

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

WIll do!

Copy link
Contributor Author

Choose a reason for hiding this comment

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


## Example

Expand All @@ -24,6 +24,12 @@ providers: [
Providers.Strava({
clientId: process.env.STRAVA_CLIENT_ID,
clientSecret: process.env.STRAVA_CLIENT_SECRET,
authorization: {
params: {
scope: process.env.STRAVA_SCOPES,
redirect_uri: `${process.env.NEXTAUTH_URL || `https:localhost:3000`}/api/auth/callback/strava`,
michaelangeloio marked this conversation as resolved.
Show resolved Hide resolved
},
},
})
]
...
Expand Down
34 changes: 0 additions & 34 deletions packages/next-auth/src/providers/strava.js

This file was deleted.

60 changes: 60 additions & 0 deletions packages/next-auth/src/providers/strava.ts
@@ -0,0 +1,60 @@
import type { OAuthConfig, OAuthUserConfig } from "."

export interface StravaProfile extends Record<string, any> {
id: string // this is really a number
username: string
resource_state: number
firstname: string
lastname: string
bio: string
city: string
state?: any
country?: any
sex: string
premium: boolean
summit: boolean
created_at: string
updated_at: string
badge_type_id: number
weight: number
profile_medium: string
profile: string
friend?: any
follower?: any
ubbe-xyz marked this conversation as resolved.
Show resolved Hide resolved
}

export default function Strava<P extends StravaProfile>(
options: OAuthUserConfig<P>
): OAuthConfig<P> {
return {
id: "strava",
name: "Strava",
type: "oauth",
authorization: {
url: "https://www.strava.com/api/v3/oauth/authorize",
params: {
scope: "read",
approval_prompt: "auto",
response_type: "code",
redirect_uri: `${process.env.NEXTAUTH_URL|| `https:localhost:3000`}/api/auth/callback/strava`,
ubbe-xyz marked this conversation as resolved.
Show resolved Hide resolved
ubbe-xyz marked this conversation as resolved.
Show resolved Hide resolved
},
},
token: {
url: "https://www.strava.com/api/v3/oauth/token",
},
userinfo: "https://www.strava.com/api/v3/athlete",
client: {
token_endpoint_auth_method: "client_secret_post",
},

profile(profile) {
michaelangeloio marked this conversation as resolved.
Show resolved Hide resolved
return {
id: profile.id,
name: `${profile.firstname} ${profile.lastname}`,
email: null,
image: profile.profile,
}
},
options,
}
}