From 64130ee4fe6c4defb17d80a5b5f7a998437662fc Mon Sep 17 00:00:00 2001 From: Lilia Date: Thu, 25 Nov 2021 21:26:15 +0400 Subject: [PATCH 1/4] fix #3360 add SoundCloud provider --- src/providers/soundcloud.js | 21 +++++++++++++++ types/providers.d.ts | 1 + types/tests/providers.test.ts | 6 +++++ www/docs/providers/soundcloud.md | 34 +++++++++++++++++++++++++ www/src/components/ProviderMarquee.js | 29 +++++++++++---------- www/static/img/providers/soundcloud.svg | 1 + 6 files changed, 78 insertions(+), 14 deletions(-) create mode 100644 src/providers/soundcloud.js create mode 100644 www/docs/providers/soundcloud.md create mode 100644 www/static/img/providers/soundcloud.svg diff --git a/src/providers/soundcloud.js b/src/providers/soundcloud.js new file mode 100644 index 0000000000..5dc32cb4cd --- /dev/null +++ b/src/providers/soundcloud.js @@ -0,0 +1,21 @@ +export default function SoundCloud(options) { + return { + id: "soundcloud", + name: "SoundCloud", + type: "oauth", + version: "2.0", + params: { grant_type: "authorization_code" }, + accessTokenUrl: "https://api.soundcloud.com/oauth2/token", + authorizationUrl: "https://api.soundcloud.com/connect?response_type=code", + profileUrl: "https://api.soundcloud.com/me", + profile(profile) { + return { + id: profile.id, + name: profile.full_name, + username: profile.username, + image: profile.avatar_url, + } + }, + ...options, + } +} diff --git a/types/providers.d.ts b/types/providers.d.ts index 8a571bf6ea..750059ed78 100644 --- a/types/providers.d.ts +++ b/types/providers.d.ts @@ -93,6 +93,7 @@ export type OAuthProviderType = | "Reddit" | "Salesforce" | "Slack" + | "SoundCloud" | "Spotify" | "Strava" | "Twitch" diff --git a/types/tests/providers.test.ts b/types/tests/providers.test.ts index ee36662440..3e052b1c0d 100644 --- a/types/tests/providers.test.ts +++ b/types/tests/providers.test.ts @@ -192,6 +192,12 @@ Providers.LinkedIn({ scope: "r_emailaddress r_liteprofile", }) +// $ExpectType OAuthConfig +Providers.SoundCloud({ + clientId: "foo123", + clientSecret: "bar123", +}) + // $ExpectType OAuthConfig Providers.Spotify({ clientId: "foo123", diff --git a/www/docs/providers/soundcloud.md b/www/docs/providers/soundcloud.md new file mode 100644 index 0000000000..94fbea13b4 --- /dev/null +++ b/www/docs/providers/soundcloud.md @@ -0,0 +1,34 @@ +--- +id: soundcloud +title: SoundCloud +--- + +## Documentation + +https://developers.soundcloud.com/docs/api/guide + +## Configuration + +https://soundcloud.com/you/apps + +## Options + +The **SoundCloud Provider** comes with a set of default options: + +- [SoundCloud Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/Soundcloud.js) + +You can override any of the options to suit your own use case. + +## Example + +```js +import Providers from `next-auth/providers` +... +providers: [ + Providers.SoundCloud({ + clientId: process.env.SOUNDCLOUD_CLIENT_ID, + clientSecret: process.env.SOUNDCLOUD_CLIENT_SECRET + }) +] +... +``` diff --git a/www/src/components/ProviderMarquee.js b/www/src/components/ProviderMarquee.js index d7b36e910a..48893e4eab 100644 --- a/www/src/components/ProviderMarquee.js +++ b/www/src/components/ProviderMarquee.js @@ -4,20 +4,21 @@ import * as S from './ProviderMarqueeStyle' import times from 'lodash.times' const icons = [ - '/img/providers/apple-black.svg', - '/img/providers/auth0.svg', - '/img/providers/aws-cognito.svg', - '/img/providers/battle.net.svg', - '/img/providers/box.svg', - '/img/providers/facebook-2.svg', - '/img/providers/github-1.svg', - '/img/providers/gitlab.svg', - '/img/providers/google-icon.svg', - '/img/providers/okta-3.svg', - '/img/providers/openid.svg', - '/img/providers/slack.svg', - '/img/providers/spotify.svg', - '/img/providers/twitter.svg' + "/img/providers/apple-black.svg", + "/img/providers/auth0.svg", + "/img/providers/aws-cognito.svg", + "/img/providers/battle.net.svg", + "/img/providers/box.svg", + "/img/providers/facebook-2.svg", + "/img/providers/github-1.svg", + "/img/providers/gitlab.svg", + "/img/providers/google-icon.svg", + "/img/providers/okta-3.svg", + "/img/providers/openid.svg", + "/img/providers/slack.svg", + "/img/providers/soundcloud.svg", + "/img/providers/spotify.svg", + "/img/providers/twitter.svg", ] const ProviderMarquee = React.memo(({ size }) => { diff --git a/www/static/img/providers/soundcloud.svg b/www/static/img/providers/soundcloud.svg new file mode 100644 index 0000000000..8125588129 --- /dev/null +++ b/www/static/img/providers/soundcloud.svg @@ -0,0 +1 @@ + \ No newline at end of file From 26d28b6c653a017c8afc8d765d2b2c09f20d8b29 Mon Sep 17 00:00:00 2001 From: Lilia Date: Thu, 25 Nov 2021 21:29:53 +0400 Subject: [PATCH 2/4] fix formatting --- www/src/components/ProviderMarquee.js | 30 ++++++++++++------------- www/static/img/providers/soundcloud.svg | 8 ++++++- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/www/src/components/ProviderMarquee.js b/www/src/components/ProviderMarquee.js index 48893e4eab..d68c40c438 100644 --- a/www/src/components/ProviderMarquee.js +++ b/www/src/components/ProviderMarquee.js @@ -4,21 +4,21 @@ import * as S from './ProviderMarqueeStyle' import times from 'lodash.times' const icons = [ - "/img/providers/apple-black.svg", - "/img/providers/auth0.svg", - "/img/providers/aws-cognito.svg", - "/img/providers/battle.net.svg", - "/img/providers/box.svg", - "/img/providers/facebook-2.svg", - "/img/providers/github-1.svg", - "/img/providers/gitlab.svg", - "/img/providers/google-icon.svg", - "/img/providers/okta-3.svg", - "/img/providers/openid.svg", - "/img/providers/slack.svg", - "/img/providers/soundcloud.svg", - "/img/providers/spotify.svg", - "/img/providers/twitter.svg", + '/img/providers/apple-black.svg', + '/img/providers/auth0.svg', + '/img/providers/aws-cognito.svg', + '/img/providers/battle.net.svg', + '/img/providers/box.svg', + '/img/providers/facebook-2.svg', + '/img/providers/github-1.svg', + '/img/providers/gitlab.svg', + '/img/providers/google-icon.svg', + '/img/providers/okta-3.svg', + '/img/providers/openid.svg', + '/img/providers/slack.svg', + '/img/providers/soundcloud.svg', + '/img/providers/spotify.svg', + '/img/providers/twitter.svg', ] const ProviderMarquee = React.memo(({ size }) => { diff --git a/www/static/img/providers/soundcloud.svg b/www/static/img/providers/soundcloud.svg index 8125588129..96768c30db 100644 --- a/www/static/img/providers/soundcloud.svg +++ b/www/static/img/providers/soundcloud.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + From a71e68f4835c707163adc9bb9b4fcaaabb65aae5 Mon Sep 17 00:00:00 2001 From: Lilia Date: Thu, 25 Nov 2021 21:33:05 +0400 Subject: [PATCH 3/4] fix formatting and provider syntax --- www/src/components/ProviderMarquee.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/src/components/ProviderMarquee.js b/www/src/components/ProviderMarquee.js index d68c40c438..36110ff437 100644 --- a/www/src/components/ProviderMarquee.js +++ b/www/src/components/ProviderMarquee.js @@ -18,7 +18,7 @@ const icons = [ '/img/providers/slack.svg', '/img/providers/soundcloud.svg', '/img/providers/spotify.svg', - '/img/providers/twitter.svg', + '/img/providers/twitter.svg' ] const ProviderMarquee = React.memo(({ size }) => { From 7722f91095debcf915d056f6af0b3a2ad3cf7562 Mon Sep 17 00:00:00 2001 From: Lilia Date: Thu, 25 Nov 2021 21:45:13 +0400 Subject: [PATCH 4/4] fix provider syntax --- www/docs/providers/soundcloud.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/www/docs/providers/soundcloud.md b/www/docs/providers/soundcloud.md index 94fbea13b4..38719cc546 100644 --- a/www/docs/providers/soundcloud.md +++ b/www/docs/providers/soundcloud.md @@ -15,17 +15,17 @@ https://soundcloud.com/you/apps The **SoundCloud Provider** comes with a set of default options: -- [SoundCloud Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/Soundcloud.js) +- [SoundCloud Provider options](https://github.com/nextauthjs/next-auth/blob/main/src/providers/soundcloud.js) You can override any of the options to suit your own use case. ## Example ```js -import Providers from `next-auth/providers` +import SoundCloudProvider from 'next-auth/providers/soundcloud'; ... providers: [ - Providers.SoundCloud({ + SoundCloudProvider({ clientId: process.env.SOUNDCLOUD_CLIENT_ID, clientSecret: process.env.SOUNDCLOUD_CLIENT_SECRET })